c++ - Template alias, Template specialization and Template Template parameters -
i want determine underlying template of template parameter using combination of template alias , template specializations. follwing code compiles fine on gcc 4.8, 6.2.1 not on clang 3.5, 3.8.
#include <iostream> template <typename t> struct first {}; template <typename t> struct second {}; template <template <typename> class f, typename t> struct foo {}; template <typename t> struct foo<first, t> { void f() { std::cout << __pretty_function__ << std::endl; } }; template <typename t> struct foo<second, t> { void f() { std::cout << __pretty_function__ << std::endl; } }; template <typename f, typename t> struct resolution {}; template <typename t> struct resolution<first<t>, t> { template <typename p> using type = first<p>; }; template <typename t> struct resolution<second<t>, t> { template <typename p> using type = second<p>; }; int main() { foo<resolution<first<int>, int>::type, float> my_foo; my_foo.f(); // main.cpp:34:12: error: no member named 'f' in 'foo<resolution<first<int>, int>::type, float>' return 0; }
which behavior standard conformant?
answer: know bug in c++ standard core language , described t.c. in comments . http://wg21.link/cwg1286
Comments
Post a Comment