The solution to the latest GotW problem is now available:
GotW #90 Solution: Factories (updated for C++11/14)
by Herb Sutter
From the article:
Guideline: A factory that produces a reference type should return aunique_ptrby default, or ashared_ptrif ownership is to be shared with the factory.Guideline: A factory that produces a non-reference type should return a value by default, and throw an exception if it fails to create the object. If not creating the object can be a normal result, return an
optional<>value.

Add a Comment
Comments are closed.