dsimcha wrote:
I've never understood the recommendation not to put complex logic in the constructor.
Complex logic is fine, just logic that cannot fail.
If you need complex logic to establish the class's invariant, or need to initialize complicated immutable data structures, where else is that logic supposed to go?
For example, allocating resources that might fail, can be done with a separate initialization function:
auto c = new Class; c.create();
