473,473 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

Why cannot I define a member of an explicitly specialized class
template out of the class template specialization:

template< int i >
struct a
{
static void Do( );
};

template< >
struct a< 2 >
{
static void Do( ); // in-class definition would be OK...
};

// .. however, neither VC 7.1, nor g++ 3.4.2,
// accept out-of-class definition:
template< >
void a< 2 >::Do( )
{
}

Jul 23 '05 #1
3 1930
BigMan wrote:
// .. however, neither VC 7.1, nor g++ 3.4.2,
// accept out-of-class definition:
template< >
void a< 2 >::Do( )
{
}

Because, "a<2>::Do()" is not a template. Try:

void a<2>::Do()
{

}

(i.e. without "template<>" at the top).

Thanks,
--
CrayzeeWulf
Jul 23 '05 #2
BigMan wrote:

Why cannot I define a member of an explicitly specialized class
template out of the class template specialization:

template< int i >
struct a
{
static void Do( );
};

template< >
struct a< 2 >
{
static void Do( ); // in-class definition would be OK...
};

// .. however, neither VC 7.1, nor g++ 3.4.2,
// accept out-of-class definition:
template< >
void a< 2 >::Do( )
{
}
...


'template <>' is used to prefix explicit specializations. If you wanted
to explicitly specialize 'a<i>::Do()' for 'i = 2' without explicitly
specializing the entire class 'a', you could do it as follows

template<int i> struct a {
static void Do( );
};

template<> void a<2>::Do() {
/* ... */
}

But it your code you decided to perform explicit specialization of the
entire class 'a'

template<> struct a<2> {
static void Do( );
};

In this case the out-of-class definition of 'a<2>::Do' has to use the
"regular" syntax

void a<2>::Do() {
/* ... */
}

It cannot be prefixed with 'template<>' in this case.

--
Best regards,
Andrey Tarasevich
Jul 23 '05 #3
Thanks a lot to both of you!

Jul 23 '05 #4

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

Similar topics

4
by: FilexBB | last post by:
Hi Folks, I have tried to redirect system.out for a while and then set it back, but it can't set it back as following program snapshot ByteArrayOutputStream baos = new ByteArrayOutputStream();...
5
by: Mike Carroll | last post by:
I have a COM server that's generally working ok. But one of its methods, when the IDL gets read by the Intertop layer, has parameters of type "out object". The C# compiler tells me that it...
4
by: Steve B. | last post by:
Hello I'm wondering what is exactly the difference between "ref" and "out" keywords. Thanks, Steve
2
by: Chua Wen Ching | last post by:
Hi there, I am wondering the difference between attribute and out keywords. Are they the same or does it serve any different purposes? I saw the and out usage in this code, and i had idea,...
9
by: Michi Henning | last post by:
Hi, I'm generating both VB and C# code from language-independent interface definitions, which is why I'm raising this issue. (The problem apppears to be somewhat esoteric, but it is real in my...
7
by: Simon Cheng | last post by:
Hi, Does MC++ support out/ref param semantics (as C# does)? The MC++ spec doesn't mention about this, so supposedly they are not supported? Thanks, Simon
6
by: nick | last post by:
For example: public static void FillRow(Object obj, out SqlDateTime timeWritten, out SqlChars message, out SqlChars category, out long instanceId)
3
by: Ashish | last post by:
hi All, Iam facing a peculiar problem, where i would like to parse the passed parameters and would like to figure out which ones are marked 'out'. For example the method signature is public...
6
by: selva | last post by:
hi, currently iam working on c# i need to pass a parameter inside a function which is a OUT parameter and i need to pass it as a reference how to do this? please help me regarding this...
6
by: carlos123 | last post by:
Ok guys, check this out! Im getting an error "Error: Index: 0, Size: 0" not sure why. try{ // Create file FileWriter fstream = new FileWriter("database.txt"); BufferedWriter...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
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...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.