473,387 Members | 1,541 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,387 software developers and data experts.

Bug: specialization of static member variables not supported ion VC7.1

Hi,
the following does not compile with VC7.1 (and I think it should according to
the C++ Standard (1998))

template<class T> struct SpecializeStaticMember
{
static int m_Num;
};

// declaration and definition of the general member variable
// (will be 0 initialized because it has static storage duration)
template<class T> int SpecializeStaticMember<T>::m_Num;

// declaration of the special member variable must be visible before
// SpecializeStaticMember<double>::m_Num gets used
template<> int SpecializeStaticMember<double>::m_Num;

// definition of the special member variable must be in
// one and only one translation unit
template<> int SpecializeStaticMember<double>::m_Num = 23.1; /* error C2086
here*/
--
Regards,

Arne
Nov 17 '05 #1
2 1211
Hi Arne,
Hi,
the following does not compile with VC7.1 (and I think it should according to the C++ Standard (1998))

template<class T> struct SpecializeStaticMember
{
static int m_Num;
};

// declaration and definition of the general member variable
// (will be 0 initialized because it has static storage duration)
template<class T> int SpecializeStaticMember<T>::m_Num;

// declaration of the special member variable must be visible before
// SpecializeStaticMember<double>::m_Num gets used
template<> int SpecializeStaticMember<double>::m_Num;

// definition of the special member variable must be in
// one and only one translation unit
template<> int SpecializeStaticMember<double>::m_Num = 23.1; /* error C2086 here*/


Whidbey gives the same error. Comeau seems to agree with you that it should
work.
I'll but it against whidbey just in case.

--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #2
Hello Arne,

Thanks for your post. Tomas is correct and I am able to reproduce the
problem in Whidbey. The issue has been entered into our database and it is
being investigated. It is possible that this may be resolved in the next
version of VS .NET, but I cannot guarantee a resolution of this issue at
this time.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #3

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

Similar topics

9
by: Patrick Kutch | last post by:
Please take a look at the following code snippit: ------------------------------------------------------- template<class TraitClass=int> class TestClass { public: void CallFunc() {...
2
by: Jonathan Turkanis | last post by:
Hi All, The simple test program at the end of this message defines a class template foo with a member function bar implemented by delegating to a static member function of a specialization of...
13
by: Eric | last post by:
I have a template class that instantiates a variable of the template parameter type as follows: template <class T> struct TemplateClass { T t; }; struct TestClass
19
by: Nicolas Fleury | last post by:
Hi everyone, I would to know what do you think of this PEP. Any comment welcomed (even about English mistakes). PEP: XXX Title: Specialization Syntax Version: $Revision: 1.10 $...
0
by: Cordell Lawrence | last post by:
Okay guys, We are wondering if this is a bug in Framework 2.0.40607 and looking for some clarification on the issue. Take a look at the folowing code. public delegate bool BoundryTest(int...
4
by: Michael Sparks | last post by:
I started writing some code with the 2.0 beta compiler, and found out quickly that specialization is not supported with generics. For example, I want to do something like this: class number...
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:
13
by: mike b | last post by:
Hello everyone, thanks in advance for your help. I'm new to C++ templates and have run into some issues using member function templates. I have a shared library containing templates that I'm...
10
by: Jeffrey | last post by:
My understanding is that if you write class X { int y; static int z; }; then you've defined (and declared) X and y, but you have only declared (and not defined) z. If you'd like to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.