Re:When noexcept?
by SamReidHughes on Thursday December 15, 2016 @03:33PM
(#13188083)
You'll get a run time error.
[ Parent
| on HN ]
Maybe. Or maybe you'll get an invisible resource leak, or silent data corruption, or an RCE vulnerability.
Re:When noexcept?
by SamReidHughes on Friday December 16, 2016 @04:52PM
(#13197219)
Well I don't know about that. If you have a datatype whose constructors can't throw, it should still assert at run time about its state that it's been initialized. Like, you have to actually do that, of course. So there's more surface area for mistakes inside the object, but from the outside of the object, which is what I think this sub-thread is talking about, they get caught at run time.
It shouldn't have to be assertions though - you should make it correct by, well, construction. When the fields are RAII the constructor can just initialize them. If your class has different possible states and flags it's usually correct to promote the different states to differnt types (subclasses).
Re:When noexcept?
by SamReidHughes on Monday December 19, 2016 @08:16PM
(#13216525)
I don't think we're disagreeing about anything. The scope of my comment is in reference to "So how do you protect yourself against inadvertently passing around uninitialized objects?" The answer is, with a run-time error.