Okay. I fail to see the point of the boost::in_place_factory. I think I understood the basics. Or maybe not since I fail to see the advantages.
It drew my attention because I'm actually doing some construction of aggregated objects through copy constructors on the aggregator class. However, I never thought a temporary object would be considered a problem.
This particular section of the documentation confuses me:
How is this a problem?There is a subtle problem with this: since the mechanism used to initialize the stored object is copy construction, there must exist a previously constructed source object to copy from. This object is likely to be temporary and serve no purpose besides being the source
A solution to this problem is to support direct construction of the contained object right in the container's storage.Code:void foo() { // Temporary object created. C c( X(123,"hello") ) ; }