top | item 46185134

(no title)

alchemio | 2 months ago

You can use std containers in a no-exceptions environment. Just know that if an error occurs the program will terminate.

discuss

order

WD-42|2 months ago

We've banned exceptions! If any occur, we just don't catch them.

elteto|2 months ago

So you can’t use them then.

account42|2 months ago

Of course you can, you just need to check your preconditions and limit sizes ahead of time - but you need to do that with exceptions too because modern operating systems overcommit instead of failing allocations and the OOM killer is not going to give you an exception to handle.

_flux|2 months ago

I don't think it would be typical to depend on exception handling when dealing with boundary conditions with C++ containers.

I mean .at is great and all, but it's really for the benefit of eliminating undefined behavior and if the program just terminates then you've achieved this. I've seen decoders that just catch the std::out_of_range or even std::exception to handle the remaining bugs in the logic, though.