このスニペットを考えると:
template <std::size_t Index, typename T, typename ...Args>
typename type_at<Index, T, Args...>::type
get(T t1, Args... args)
{
return
static_cast<type_at<Index, T, Args...>::type>
(
reinterpret_cast<void*>
(
value_at<Index, T, Args...>::get(t1, args...)
)
);
}
int main()
{
int * a = new int(10);
double* b = new double(3.14);
std::string c = "But I'm a string :(";
std::cout<< *get<0>(a, b, &c) <<"\n";
std::cout<< *get<1>(a, b, &c) <<"\n";
std::cout<< *get<2>(a, b, &c) <<"\n";
}
GCC 4.8.1では機能しませんが、VS2012ではNov CTPコンパイラを使用してコンパイルおよび実行できます(ちなみにclangは試していません)
どのコンパイラが正しいですか?