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? 6 2810
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
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?
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?
On Fri, 06 Jan 2006 19:14:54 +0300, rincewind <fa**@not.rea l> 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.
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.
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 > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 18.3.1, 'Iseq'). I want the version for containers that he
gives, but also to provide a specialization for construction from a
pair<It,It> (eg because that is returned by equal_range()).
|
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 like this:
----8<---
typedef char IsPODForListArrayTrue;
|
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 specialize
Music<Bach>, I expect that the original play() method is available
in the specialization, but it is not. How can I fix this?
-X
|
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 above:
at line 3:
error C2989: 'B<struct A<T> >' : template class has already been
defined as a non-template class
|
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 advance..
| |
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>
|
by: Alfonso Morra |
last post by:
Does VC 7.1 support template specialization and partial specialization ?
|
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 A<T,3>::f (T) {
|
by: Ioannis Gyftos |
last post by:
Hello,
First the code :)
///////////////////////////////////////////////////////////////////////////////////
// in another header file
namespace LJC{
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |