Is this template syntax illegal?

template <typename T, typename, int, template <typename U, U, U> class>
  struct Sort;  

This is perfectly legal.

It could be redeclared like this, giving names to all the parameters:

template <typename T, typename T2, int I, template <typename U, U X, U Y> class TT>
  struct Sort;  

It declares a class template Sort which has four template parameters, the type parameter T, a second type parameter T2 (unnamed in the original), a non-type template parameter I, and a template template parameter TT.

The template template parameter TT must a class template taking three template parameters, U is a type parameter and the second and third (X and Y) are non-type template parameters of type U.

A suitable argument for the fourth template parameter of Sort might be something like:

template <typename T, T t1, T t2>
  class Foo
  { static const bool value = t1 < t2; };

which would be instantiated like:

Foo<int, 1, 2> fi;

or

Foo<char, 'a', 'b'> fc;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)