123456789101112131415
#include <iostream> #include <tuple> template < typename unused = void > struct TC { template < typename T > static auto value(T const& t) { return std::make_tuple( t ); } template < typename T > using value_type = decltype( value( T() ) ); };
12345678910111213141516171819
#include <iostream> #include <tuple> #include <utility> template < typename unused = void > struct TC { template < typename T > static auto value(T const& t) { return std::make_tuple( t ); } // http://en.cppreference.com/w/cpp/utility/declval template < typename T > using value_type = decltype( value( std::declval<T>() ) ); }; int main() { struct A { A(int) {} } a(22) ; TC<>::value_type<A> tup = TC<>::value<A>(a) ; static_assert( std::is_same< std::tuple<A>, decltype(tup) >::value, "unexpected type" ) ; }