C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

'Unspecialize' template?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
wong.kam.keung@gmail.com
Guest





PostPosted: Wed Oct 12, 2005 12:57 am    Post subject: 'Unspecialize' template? Reply with quote



Hi all,

I want to remove a template specialization by using another template to
match the specialized template. Is it possible?

template <typename T>
struct remove_ptr;

template <typename T>
struct remove_ptr<T*>
{
typedef T type; // <-- removed point to T
};

template struct remove_specialize;

template <typename T, typename X>
struct remove_specialize<T // <-- compile error
{
typedef T type;
};


Thanks.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Greg Herlihy
Guest





PostPosted: Wed Oct 12, 2005 4:37 pm    Post subject: Re: 'Unspecialize' template? Reply with quote



[email]wong.kam.keung (AT) gmail (DOT) com[/email] wrote:
Quote:
Hi all,

I want to remove a template specialization by using another template to
match the specialized template. Is it possible?

It is possible to use a template to break apart a template
specialization into the class template and the parameterized type (see
below).

Quote:
template <typename T
struct remove_ptr;

template struct remove_ptr {
typedef T type; // <-- removed point to T
};

template struct remove_specialize;

template struct remove_specialize // <-- compile error
{
typedef T type;
};

To accomplish the first step (separating the class template from its
specialized type) requires a class template that accepts a template
template parameter:

template