> Exceptions opponents have devised many ways of dealing with errors in constructors. They all boil down to this pattern:
myobj obj;
obj.complete_initialization();
Do they? How about the constructor-that’s-not-a-constructor pattern: myobj::create(…);
And have that return an option or result type? This is the normal way to do this in several languages (Rust, but also plenty of functional languages), and C++ can do it too, awkwardly, using private constructors and public static helpers. (Awkward because the object may still need to exist, temporarily, in a partially constructed state outside a constructor.)I wonder whether coroutines in C++ could pull this off without being too tedious.