c++ - Is this template syntax illegal? -
i'm getting "internal compiler error" using gcc 4.9.2:
#include <type_traits>  template <typename t, typename, int, template <typename u, u, u> class> struct sort;  template <typename t, template <t...> class z, t n, t... is,           template <typename u, u, u> class comparator> struct sort<t, z<n, is...>, 0, comparator> {   template <t i>   struct less_than : std::integral_constant<bool, comparator<t, i, n>::value> {   }; };  int main() {} the error message states:
c:\adandd>g++ -std=c++14 comparatorandsortertgeneralized.cpp comparatorandsortertgeneralized.cpp:254:80: internal compiler error: in tsubst, @ cp/pt.c:11738
template<t i> struct less_than : std::integral_constant<bool, comparator<t,i,n>::value> {}; ^please submit full bug report, preprocessed source if appropriate. see http://gcc.gnu.org/bugs.html instructions.
the issue template <typename u, u, u> class comparator being used. i've never tried before. @ first tried template <typename t, t, t> class comparator, not compile because of template shadowing, knew illegal. , changing u still did not compile, thought whole idea not allowed. 
update: upon instantiating, compiles in visual studio 2015 preview:
#include <type_traits>  template <typename t, typename, int, template <typename u, u, u> class> struct sort;  template <typename t, template <t...> class z, t n, t... is,           template <typename u, u, u> class comparator> struct sort<t, z<n, is...>, 0, comparator> {   template <t i>   struct less_than : std::integral_constant<bool, comparator<t, i, n>::value> {   }; };  template <int...> struct index_sequence {};  template <typename t, t a, t b>     struct lessthan : std::integral_constant < bool,     a<b> {};  enum { quicksort, mergesort, insertionsort };  int main() {   sort<int, index_sequence<4, 5, 6, 1, 2, 7>, quicksort, lessthan> quicksort; } 
template <typename t, typename, int, template <typename u, u, u> class>   struct sort;   this legal.
it redeclared this, giving names parameters:
template <typename t, typename t2, int i, template <typename u, u x, u y> class tt>   struct sort;   it declares class template sort has 4 template parameters, type parameter t, second type parameter t2 (unnamed in original), non-type template parameter i, , template template parameter tt.
the template template parameter tt must class template taking 3 template parameters, u type parameter , second , third (x , y) non-type template parameters of type u.
a suitable argument fourth template parameter of sort might like:
template <typename t, t t1, t t2>   class foo   { static const bool value = t1 < t2; }; which instantiated like:
foo<int, 1, 2> fi; or
foo<char, 'a', 'b'> fc;