C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Partial class template specialization fails to compile with

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
archondas
Guest





PostPosted: Thu Dec 30, 2004 8:16 pm    Post subject: Partial class template specialization fails to compile with Reply with quote



Dear C++ fellows,
Any special reason why the following code,
doesn't compile with Visual C++ 6.0 with Service Pack 6.0
while it compiles nicely with devcpp 5.0 or with any gnu-g++?

Here is the code!
-----------------
#include <iostream>
using std::cout;
using std::endl;

template<typename A, typename B>
class MyClass
{
};

template<typename A>
class MyClass<A, double>
{
public:
MyClass()
{
cout << "B = doublen";
}
};

template class MyClass<int, B>
{
public:
MyClass()
{
cout << "A = intn";
}
};

int main()
{
MyClass MyClass<int, char> b;
return 0;
}






[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Brendan Bond
Guest





PostPosted: Fri Dec 31, 2004 1:14 pm    Post subject: Re: Partial class template specialization fails to compile w Reply with quote



archondas wrote:
Quote:
Dear C++ fellows,
Any special reason why the following code,
doesn't compile with Visual C++ 6.0 with Service Pack 6.0
while it compiles nicely with devcpp 5.0 or with any gnu-g++?

Visual C++ 6.0 is infamous for not being compliant with C++ standards.
It's a good bet that, if your code successfully compiles with gcc, the
errors come from Visual C++ 6.0's faults and not your code. I
recommend getting your hands on the latest Visual C++ compiler, both of
which (2003 .NET edition and the freely available 2005 Express Beta)
are very standards compliant.

-Brendan Bond


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
L.Suresh
Guest





PostPosted: Fri Dec 31, 2004 1:17 pm    Post subject: Re: Partial class template specialization fails to compile w Reply with quote



Does'nt have any problems. What error message did it give?
What about Visual C++ 7.0?

--lsu


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Bo Persson
Guest





PostPosted: Fri Dec 31, 2004 1:20 pm    Post subject: Re: Partial class template specialization fails to compile w Reply with quote


"archondas" <dkouroun (AT) cc (DOT) uoi.gr> skrev i meddelandet
news:35bf40ae065ff8add90ca7b423c55121 (AT) localhost (DOT) talkaboutprogramming.com...
Quote:
Dear C++ fellows,
Any special reason why the following code,
doesn't compile with Visual C++ 6.0 with Service Pack 6.0
while it compiles nicely with devcpp 5.0 or with any gnu-g++?

Yes, VC6 is an ancient compiler, model 1998. There are lots of things it
cannot handle, especially when it comes to templates. Partial
specialization is one of those.


Bo Persson



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Gerd Orfey
Guest





PostPosted: Sat Jan 01, 2005 1:17 am    Post subject: Re: Partial class template specialization fails to compile w Reply with quote

archondas wrote:
Quote:
Dear C++ fellows,
Any special reason why the following code,
doesn't compile with Visual C++ 6.0 with Service Pack 6.0
while it compiles nicely with devcpp 5.0 or with any gnu-g++?

Here is the code!
-----------------
#include <iostream
using std::cout;
using std::endl;

template class MyClass
{
};

template class MyClass {
public:
MyClass()
{
cout << "B = doublen";
}
};

template class MyClass {
public:
MyClass()
{
cout << "A = intn";
}
};

int main()
{
MyClass MyClass<int, char> b;
return 0;
}


Your program compiles fine with VC++7.1. So maybe its an option to use the
MS Visual C++ Toolkit 2003. Wich is compiler, linker and standard libraries
of Visual
Studio 2003 Professional, for free (no IDE). As far as I could see, there is
no
MFC and/or ATL support in this package. But I might be wrong.


More info here: http://msdn.microsoft.com/visualc/vctoolkit2003/

Search in the various news:microsoft.public.vc. newsgroups for help on
integrating
the toolkit with the VC6 IDE etc.

Regards

Gerd





[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
glongword
Guest





PostPosted: Sat Jan 01, 2005 9:29 am    Post subject: Re: Partial class template specialization fails to compile w Reply with quote

Even VS.NET 2003 (7.1.3088) doesn't seem to handle template template
arguments. This code (stripped down basics/stack8.hpp from "C++
Templates" by David Vandevoorde and Nicolai Josuttis) doesn't compile.
Dev C++ 5 runs it, though.

#include <deque>

template <typename T,
template
class S>
class A
{
S<T> s;
};

int main()
{
A<int, std::deque> a;
}


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
David Abrahams
Guest





PostPosted: Sun Jan 02, 2005 9:27 am    Post subject: Re: Partial class template specialization fails to compile w Reply with quote

archondas wrote:
Quote:
Dear C++ fellows,
Any special reason why the following code,
doesn't compile with Visual C++ 6.0 with Service Pack 6.0
while it compiles nicely with devcpp 5.0 or with any gnu-g++?

MSVC didn't acquire support for partial specialization until version 7.1

HTH,
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.