Specializing a template template-parameters with a template template class.

Specializing a template template-parameters with a template template class.

Post by itaj sherm » Fri, 11 Mar 2011 16:21:45



Has the standard ever considered the option of defining template of
template of class?

Why should it not be possible to define:
template< typename T1, typename T2 > template< typename U1, typename
U2, typename U3 > class Y {};
Y is a template with 2 parameters of a template with 3 parameters of a
class.
Which would make X< A, B > a template class with 3 parameters.

The natural transform to:
template< typename T1, typename T2, typename U1, typename U2, typename
U3 > class X {};
is not equivalent in c++ with respect to partial specialization.

The problem was raised in this thread in comp.lang.c++, but with no
much resolution to this particular issue.
http://www.yqcomputer.com/ ++/browse_frm/thread/e5f4456dd3182753#

To demonstrate the problem:

template< template< typename T > class > class A;
class B {};

template< typename T, typename U > class X {};
//and hypothetic equivalent:
template< typename T > template < typename U > class Y {};
//or
template< typename T > template < typename U > using Y = X< T, U >;

Using the above hypothetical syntax, Y and X could be considered
equivalent X< T, U > == Y< T >< U >.
However, for any type T, Y<T> is a template class (with 1 parameter),
and it might make sense to be able to specialize the first parameter
of A on Y<T>:

//hypothetically specialize:
template< typename T > class A< Y<T> > {};
//instanciated by A< Y<B> >

With X it's not possible to do such specialization.

Nesting cannot solve that either:

template< typename T > class Z
{
public: template< typename U > class R {};
};

template< typename T > class A< Z<T>::R > {};
//cannot instanciate by A< Z<B>::R >

It's not possible to deduce T in a member template class Z<T>::R.

Has this ever been considered as a c++ feature?

itaj
 
 
 

1. Specializing a template template-parameters with a template template class.

2. Specializing a template template-parameters with a template template class.


I don't see how the template aliases would solve this by themelves.
How would you define that specialization of A?

itaj


--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto: XXXX@XXXXX.COM ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.yqcomputer.com/ ]

3. Inability to explicitly specialize a template class within another non-specialized template class

4. Need traits class that defines class template for template template parameter

5. Need traits class that defines class template for template template parameter

6. Need traits class that defines class template for template template parameter

7. Need traits class that defines class template for template template parameter

8. Out-of-class definition of a non-template member of an explicitly specialized class template?

9. how to partially specialize a template class nested inside another template class?

10. overloading on the template parameter arity of a template template parameter

11. Copying a template class into another template class object with different no of templates

12. Declaring a template class with two template params a friend in a non-template class

13. Declaring a template class with two template params a friend in a non-template class

14. specialize a template function that contains a template parameter

15. template class with template member function, want to specialize the member function