Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Modern CPP Design related (http://www.velocityreviews.com/forums/t284003-modern-cpp-design-related.html)

LRS Kumar 06-25-2004 11:44 AM

Modern CPP Design related
 
In Section 1.4 of Alexandrescu's Modern C++ Design, he states the
following:

<quote>
1. You cannot specialize structure. Using templates alone you cannot
specialize the structure of a class (its data members). You can only
specialize only functions.
</quote>

What does the author mean by that? Wouldn't the following constitute
"specializing structure"?

template<typename T>
class A {
T t;
};

template<>
class A<int> {
float t;
std::string s;
};


Thanks in advance for your time.

Terribly confused,
LRS

Wolfgang Meyer 06-26-2004 12:26 AM

Re: Modern CPP Design related
 
LRS Kumar wrote:

> In Section 1.4 of Alexandrescu's Modern C++ Design, he states the
> following:
>
> <quote>
> 1. You cannot specialize structure. Using templates alone you cannot
> specialize the structure of a class (its data members). You can only
> specialize only functions.
> </quote>
>
> What does the author mean by that? Wouldn't the following constitute
> "specializing structure"?
> [...]


Yes, it does. But the point is that you have to repeat the whole class
definition while for member _functions_ you can specialize just one
function.
See:
http://groups.google.com/groups?hl=e....de%26rnum%3D5

Here Alexandrescu answers exactly this questions.

Wolfgang


LRS Kumar 06-26-2004 02:35 PM

Re: Modern CPP Design related
 
Wolfgang Meyer <Wolfgang.Meyer@gmx.net> wrote in message news:<40dca689$0$12451$9b622d9e@news.freenet.de>.. .
>
> Yes, it does. But the point is that you have to repeat the whole class
> definition while for member _functions_ you can specialize just one
> function.
> See:
> http://groups.google.com/groups?hl=e....de%26rnum%3D5
>
> Here Alexandrescu answers exactly this questions.
>
> Wolfgang


Thanks a lot. That link helped.

LRS


All times are GMT. The time now is 10:07 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.