The following function, toArray
, might one day convert a C++11 std::tuple
into a C++11 std::array
:
#include <tuple>
#include <array>
template <typename T, typename ...U>
std::array<T,sizeof...(U)>
toArray(std::tuple<U...>) {
return std::array<T,sizeof...(U)>();
}
If I try to call toArray
with the following code, under G++ 4.8 I can compile successfully. Compiling with Clang++ 3.2, however, crashes the Clang front-end. Is my code valid C++?
int main(int argc, char *argv[])
{
auto tup = std::make_tuple(1,2,3,4,5,6,7,8);
toArray<int>(tup);
return 0;
}