473,422 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,422 software developers and data experts.

Arguments in partial template specialization

Hi,

can anybody summarise all options for partial template specialization,
for all kind of parameters (type, nontype, template)?

I *think* I understand options for partial specialization on type
parameters - in place of a template argument one can construct arbitrary
valid C++ type declaration, more or less like in "typedef" statement.

What about nontype parameters? Am I right that you cannot partially
specialize on nontype parameters at all - you either leave the parameter
as it is in the primary template, or fully specialize it by passing a
constant as an argument?

Finally, what are the options for template template parameters?
Jan 6 '06 #1
6 2782
rincewind wrote:
can anybody summarise all options for partial template specialization,
for all kind of parameters (type, nontype, template)?

I *think* I understand options for partial specialization on type
parameters - in place of a template argument one can construct arbitrary
valid C++ type declaration, more or less like in "typedef" statement.

What about nontype parameters? Am I right that you cannot partially
specialize on nontype parameters at all - you either leave the parameter
as it is in the primary template, or fully specialize it by passing a
constant as an argument?

Finally, what are the options for template template parameters?


Partial specialisation is not just for one-argument templates. Templates
with more than one argument can be partially specialised by specifying one
or more, but not all, arguments.

template<int i, char c> class Foo {};
template<int i> class Foo<i,'A'> {}; // partial specialisation

So, every time you narrow down the set of possible instantiations of
a template, you make it specialised. You can for example specialise this
template:

template< template<class> class container > class Foo {};

by making it a different template

template< class T > class MyContainer {};
template< class T > class Foo<MyContainer> {};

V
Jan 6 '06 #2
Victor Bazarov wrote:
Partial specialisation is not just for one-argument templates.


Yes, sure, but when you narrow down the set of possible instantiations,
you do it for (at least) one template parameter. I basically asked
whether you can *partially* specialize for nontype or template parameters?
Jan 6 '06 #3
Victor Bazarov wrote:
Partial specialisation is not just for one-argument templates.


Yes, sure, but when you narrow down the set of possible instantiations,
you do it for (at least) one template parameter. I basically asked
whether you can *partially* specialize for nontype or template parameters?
Jan 6 '06 #4
On Fri, 06 Jan 2006 19:14:54 +0300, rincewind <fa**@not.real> wrote:

Rincewind is that you? Makes perfect sense you double posted. I mean
your Rincewind right. :-) It's me Death.

Don't think of it as dying, said Death. Just think of it as leaving
early to avoid the rush. - Terry Pratchett (I left out the caps so as
not to freakout the netcops.) :-) Oh, too late.
Jan 6 '06 #5
rincewind wrote:
Victor Bazarov wrote:
Partial specialisation is not just for one-argument templates.

Yes, sure, but when you narrow down the set of possible instantiations,
you do it for (at least) one template parameter. I basically asked
whether you can *partially* specialize for nontype or template parameters?


A non-type template argument, no. A template template argument - yes,
and I've shown it. Look again.
Jan 6 '06 #6

rincewind wrote:
Victor Bazarov wrote:
Partial specialisation is not just for one-argument templates.


Yes, sure, but when you narrow down the set of possible instantiations,
you do it for (at least) one template parameter. I basically asked
whether you can *partially* specialize for nontype or template parameters?


template< template<class> class container > class Foo {};

is when you want to pass generically defined types such as vectors

Foo<vector<Type> >

Jan 7 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Paul MG | last post by:
Hi Template partial specialization always seems like a fairly straightforward concept - until I try to do it :). I am trying to implement the input sequence type (from Stroustrup section...
9
by: Philip Lawatsch | last post by:
Hi I'd like to implement some kind if type traits myself, but I have to support broken compilers (like visual studio) that do not support Partial Specialization. My first shot was something...
8
by: Agent Mulder | last post by:
Hi group, I have a problem with partial template specialization. In the code below I have a template struct Music with one method, play(), and three kinds of music, Jazz, Funk and Bach. When I...
2
by: Shekhar | last post by:
template<typename T> struct A{}; //line 1 template<typename T> struct B{}; //line 2 template<typename T> struct B<A<T> > {}; //line 3: partial specialization of B VC6.0 compiler results for the...
1
by: BekTek | last post by:
I'm still confused about the template partial specialization which is used in many libraries.. due to lack of introduction for beginner.. Could you tell me about that in short? Thanks in...
5
by: Levent | last post by:
Hi, Why doesn't this work? (tried with gcc 3.3.3 and VC++ 7.1): #include <iostream> template<class T, unsigned N> struct Foo { void func(); }; template<class T, unsigned N>
4
by: Alfonso Morra | last post by:
Does VC 7.1 support template specialization and partial specialization ?
10
by: jason.cipriani | last post by:
I never seem to be able to get this right. Here I have some code: template <typename T, int Nclass A { void f (T); }; template <typename Tvoid A<T,1>::f (T) { } template <typename Tvoid...
1
by: Ioannis Gyftos | last post by:
Hello, First the code :) /////////////////////////////////////////////////////////////////////////////////// // in another header file namespace LJC{
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.