Hacker News new | past | comments | ask | show | jobs | submit login

Exceptions are an optional feature. Also, if sufficient amount of constructors are marked noexcept, then the variant can never be valueless. Implementations are optimized accordingly.

You also don't have to handle the exception, in which case you won't access the variant again anyway. Or it gets handled where the variant is teared down. It's very unlikely that it gets handled where the variant is constructed or assigned to, making it a non-issue.




They aren't as per ISO C++, even though all compilers allow to disable them in non standard conforming ways.


I meant exceptions as a user of the language. You can decide not to throw. You can mark functions noexcept.

Granted, it's more awkward when you consume 3rd party libraries, but you can still wrap them in noexcept interfaces and be fine with terminating when an exception is actually thrown or do something else. Not much different to a panic.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: