Consider:
std::tuple<bool, double, int> getTuple()
{
return {};
}
What does the standard say about the values in the resulting tuple in this case? Is it guaranteed that e.g. the bool is always false?
Consider:
std::tuple<bool, double, int> getTuple()
{
return {};
}
What does the standard say about the values in the resulting tuple in this case? Is it guaranteed that e.g. the bool is always false?
The default constructor of tuple
is specified to value-initialize all elements, see case 1 in cppreference link.
In brief, value-initialization is the same as if the element were initialized by {}
(there are corner cases I'm omitting). For primitive types this means bool
is false
, double
is 0.0
and int
is 0
.