Modern CPP Design related

Discussion in 'C++' started by LRS Kumar, Jun 25, 2004.

  1. LRS Kumar

    LRS Kumar Guest

    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
     
    LRS Kumar, Jun 25, 2004
    #1
    1. Advertising

  2. 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=...%24dgha6%241%40ID-14036.news.dfncis.de&rnum=5

    Here Alexandrescu answers exactly this questions.

    Wolfgang
     
    Wolfgang Meyer, Jun 26, 2004
    #2
    1. Advertising

  3. LRS Kumar

    LRS Kumar Guest

    Wolfgang Meyer <> wrote in message news:<40dca689$0$12451$>...
    >
    > 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=...%24dgha6%241%40ID-14036.news.dfncis.de&rnum=5
    >
    > Here Alexandrescu answers exactly this questions.
    >
    > Wolfgang


    Thanks a lot. That link helped.

    LRS
     
    LRS Kumar, Jun 26, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DrUg13
    Replies:
    1
    Views:
    490
    DrUg13
    Feb 10, 2004
  2. Alex Vinokur
    Replies:
    7
    Views:
    420
    Greg Comeau
    Nov 15, 2004
  3. Michael

    Modern C++ Design

    Michael, Nov 30, 2004, in forum: C++
    Replies:
    4
    Views:
    411
    Matthias =?ISO-8859-1?Q?K=E4ppler?=
    Nov 30, 2004
  4. Vinu
    Replies:
    9
    Views:
    663
  5. www.hitechskill.com
    Replies:
    0
    Views:
    1,378
    www.hitechskill.com
    Apr 9, 2006
Loading...

Share This Page