3 ms·
C++ constructors can't return error codes or Result. That's the two-stage initialization (constructor call + initialize() call) wvenable is talking about. (Of
by Arnavion 10y ago
C++ constructors can't return error codes or Result. That's the two-stage initialization (constructor call + initialize() call) wvenable is talking about.
(Of course you could do the same thing as Rust and expose only a static creator function and hide the actual constructor.)
- vvanders 10y agoYeah, most projects I worked on was doing the static creator before Rust showed up on the scene since it sidesteps a lot of these issues.