Re:C++11 Tuple Implementation Details (2012)
by Kranar on Saturday February 06, 2021 @02:09AM
(#26044755)
Yep, that's the idea. It's done in several parts of the standard library to in-place construct objects, usually via std::piecewise_construct.
>It wouldn't work if, e.g., later elements of the tuple are constructed with pointers into earlier elements...
That's right but there's no way to construct a tuple in this manner. You can construct a tuple with some default values and then after construction have elements of the tuple point to others, but you couldn't possibly construct a tuple where elements of the tuple are pointing to one another.
I suppose that works, as long as you can determine all the construction arguments in advance. It wouldn't work if, e.g., later elements of the tuple are constructed with pointers into earlier elements, so that you'd need the earlier elements to already be constructed before computing the construction arguments for the later elements.