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

Template specialization and partial specialization

Does VC 7.1 support template specialization and partial specialization ?

Nov 17 '05 #1
4 1823
Alfonso Morra wrote:
Does VC 7.1 support template specialization and partial
specialization ?


Yes.
Nov 17 '05 #2


Carl Daniel [VC++ MVP] wrote:
Alfonso Morra wrote:
Does VC 7.1 support template specialization and partial
specialization ?

Yes.


Do I have to define my specializations insitu (in header file), or can I
define them elsewhere (in a .cpp file)?. There seems to be some
confusion in this matter, wrt VC 7.1

Nov 17 '05 #3
Alfonso Morra wrote:
Carl Daniel [VC++ MVP] wrote:
Alfonso Morra wrote:
Does VC 7.1 support template specialization and partial
specialization ?


Yes.


Do I have to define my specializations insitu (in header file), or
can I define them elsewhere (in a .cpp file)?. There seems to be some
confusion in this matter, wrt VC 7.1


All template definitions, specialization or not, must be visible at the
point of use. In practice, that means they must be in a header file.

At present, this is true for all C++ compilers except Comeau, which remains
the only compiler to have a supported implementation of the C++ 'export'
facility. Using 'export', you can place your template deifnitions in a
"cpp" file.

-cd
Nov 17 '05 #4
Alfonso Morra wrote:


Carl Daniel [VC++ MVP] wrote:
Alfonso Morra wrote:
Does VC 7.1 support template specialization and partial
specialization ?


Yes.


Do I have to define my specializations insitu (in header file), or can I
define them elsewhere (in a .cpp file)?. There seems to be some
confusion in this matter, wrt VC 7.1


Declarations of all partial class template and explicit function and
class template specializations should always go in headers (for all
compilers), since the declaration of a specialization must appear before
that specialization is used, otherwise the code has undefined behaviour.
Explicit class template specializations should also be defined in the
header (otherwise they will be incomplete types).

Definitions of members of partial specializations should generally go in
headers (except when your compiler supports "export", which VC does not).

Definitions of explicit function template specializations or members of
explicitly specialized class templates should go in .cpp files (unless
declared inline, or defined in the class body).

I hope that is reasonably clear. Visual C++ implements the "Borland"
model of template instantiation, where definitions of non-explicit
template specializations must always be visible at the point of
instantiation.

Tom
Nov 17 '05 #5

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

Similar topics

17
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...
8
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...
4
by: TT \(Tom Tempelaere\) | last post by:
Comeau compiler complains (too few arguments for class template "B") at line *** #include <memory> template<typename T, size_t n> struct A {}; template<typename T, size_t n> struct B;
1
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...
5
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>
9
by: Marek Vondrak | last post by:
Hello. I have written the following program and am curious why it prints "1" "2". What are the exact effects of explicitly providing function template parameters at the call? Is the second...
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. ...
8
by: flopbucket | last post by:
Hi, I want to provide a specialization of a class for any type T that is a std::map. template<typename T> class Foo { // ... };
1
by: Ioannis Gyftos | last post by:
Hello, First the code :) /////////////////////////////////////////////////////////////////////////////////// // in another header file namespace LJC{
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.