I would like to "materialize" a variadic types list into an initializer_list of related values.
For example, having an std::tuple
of several std::integral_constant<T, x>
get an std::initializer_list<T>{...}
.
In general case, I would like to get initializer_list of some complex type, like std::string
.
But the following simple example gives me a crash when compiled by Clang (although it works with GCC, at least on Coliru), so I suspect UB (or bug in Clang):
template <class... Ts>
std::initializer_list<const std::string> materialize()
{
return {
std::to_string(Ts::value)...
};
}
void print_out()
{
for (const auto & x : materialize<std::true_type, std::false_type>()) {
std::cout << x << "\n";
}
}
So, is such code legal? In C++11/14/17?
std::initializer_list
instances, too. – Kreg