473,405 Members | 2,262 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,405 software developers and data experts.

[BUG]? explicit specialization of templates

I have a query concerning the handling of explicit specializations.
Essentially, I want to know whether it is legal to take a template
like
template<class X> typename X::A Foo(typename X::B, typename X::C)
and specialise it in the case X takes some particular value, such as:
template<> typename Bar::A Foo<Bar>(typename Bar::B, typename Bar::C)


Here is a complete example of what I am trying to do
-------------------------------------------------
template<class linktype> typename linktype::mychildset&
GetCList(typename linktype::parent&,linktype* =0);

struct UniqueID
{
typedef int mychildset;
typedef int parent;
};

int k;

template<> UniqueID::mychildset& GetCList<UniqueID>(UniqueID::parent&
par,UniqueID*)
{
return k;
}

int main()
{
return 0;
}

-------------------------------------------------

..NET 2003 will not compile this code, giving the error message
"explicit specialization; 'UniqueID::mychildset
&GetCList<UniqueID>(UniqueID::parent &,UniqueID *)' is not a
specialization of a function template", whereas the original .NET
accepted it. I was wondering whether this was due to enhanced
standards conformance in '03, or whether it might have some other
cause (e.g. a compiler bug). (BTW, I tried the code on
www.comeaucomputing.com, which accepted it.) Any information
gratefully recieved!

Best,

Thomas Barnet-Lamb
Lionhead Studios Ltd.
www.lionhead.com
Nov 16 '05 #1
1 1502
"Thomas Barnet-Lamb" <tb****@lionhead.com> wrote:
[...]
template<class linktype> typename linktype::mychildset&
GetCList(typename linktype::parent&,linktype* =0);

struct UniqueID
{
typedef int mychildset;
typedef int parent;
};

int k;

template<> UniqueID::mychildset& GetCList<UniqueID>(UniqueID::parent&
par,UniqueID*)
{
return k;
}

int main()
{
return 0;
}
[...]

Comeau is happy with your code:

--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--

Thank you for testing your code with Comeau C/C++!
Tell others about http://www.comeaucomputing.com/tryitout !

Your Comeau C/C++ test results are as follows:

Comeau C/C++ 4.3.1 (Mar 1 2003 20:09:34) for ONLINE_EVALUATION_BETA1
Copyright 1988-2003 Comeau Computing. All rights reserved.
MODE:strict errors C++

In strict mode, with -tused, Compile succeeded (but remember, the Comeau
online compiler does not link).

--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--

Schobi

--
Sp******@gmx.de is never read
I'm Schobi at suespammers org

"My hair style calls into immediate question all my judgements."
Scott Meyers

(http://www.google.de/groups?selm=MPG...ws.hevanet.com)


Nov 16 '05 #2

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

Similar topics

4
by: CoolPint | last post by:
I would be grateful if someone could point out if I am understanding correctly and suggest ways to improve. Sorry for the long message and I hope you will kindly bear with it. I have to make it...
0
by: Patrick Kowalzick | last post by:
Dear all, the following code is illegeal (but compiles with MSVC 7.1): // *** illegal *** struct outer0 { template<typename inner_var> struct inner { }; template<>
11
by: Gernot Frisch | last post by:
// variable creation object template <class T> class CL { public: CL (const T& t) {} template <> CL<double>(const T& t) {} }; How do I make a constructor for T = double, ..., so I can...
6
by: Vyacheslav Lanovets | last post by:
Hello, All! I know that Explicit Instantiation actually emits code to obj files (so you can even export them from the module as plain functions or classes). But I found that MSVC7.1 compiler...
2
by: Michael Stembera | last post by:
Here is a very simple piece of code to repro this bug. template<typename T, int N> inline bool foo( void ) { return true; } template<typename T> inline bool foo<T, 1>( void ) { return...
3
by: Dilip | last post by:
I am stumbling my way through C++ templates and I keep running into way too many questions. Here is one: If a library writer exposes a function template like so: template<typename T> void...
3
by: Steven T. Hatton | last post by:
Has anybody here used explicit instantiation of templates? Has it worked well? Are there any issues to be aware of? -- NOUN:1. Money or property bequeathed to another by will. 2. Something...
9
by: stephen.diverdi | last post by:
Can anyone lend a hand on getting this particular template specialization working? I've been trying to compile with g++ 4.1 and VS 2005. ...
2
by: Barry | last post by:
The following code compiles with VC8 but fails to compiles with Comeau online, I locate the standard here: An explicit specialization of any of the following:
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
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,...
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...

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.