Aggregate initialization requires among other things no user-provided constructors. But std::tuple
and std::pair
pair have a large set of overloaded constructors. From the point of the core language, are these constructors user-provided or even user-declared ?
With C++17 it will be possible to write (update/clarification: where nocopy is a class that can not be copied or moved, such as std::mutex
)
auto get_ensured_rvo_str(){
return std::pair(std::string(),nocopy());
}
edit: no, it's not possible as explained in the linked to answers and the answer below.
which requires aggregate initialization (for context: Multiple return values (structured bindings) with unmovable types and guaranteed RVO in C++17).
Are tuple
and pair
backed by special standard language to allow this (in presence of constructors) ? :
20.5.2.1 Construction
... EXPLICIT constexpr tuple(const Types&...);
6 Effects: The constructor initializes each element with the value of the corresponding parameter.
or can we in principle write our own tuple
or pair
?