Another "is this C++" question for the language lawyers

Discussion in 'C++' started by Evan, Dec 5, 2006.

  1. Evan

    Evan Guest

    template <class CharT >
    struct ctype_byname {
    ctype_byname();
    };


    template < >
    ctype_byname<char>::ctype_byname<char>();

    This code compiles with GCC 3.4.4, Sun CC 5.8, and MSVC 7.1. It fails
    to compile with GCC 4.1.1, Intel CC 9.1, and Comeau's online compiler.

    So... who's got it right?

    My hunch from the fact that GCC used to accept it and now doesn't, plus
    the fact that Comeau rejects it, is that it's probably not legal, but
    can anyone verify this?

    I've got a copy of the standard, so feel free to cite it if you happen
    to look there anyway, but I have no clue where to look really. (I read
    through 14.7 but to no avail. I wonder if maybe there's something
    relating to this with all the blah-ids in 14.7.2 para 2, but I don't
    know the standard well enough to make that determination.)

    Thanks,
    Evan
     
    Evan, Dec 5, 2006
    #1
    1. Advertising

  2. Evan

    Kai-Uwe Bux Guest

    Evan wrote:

    > template <class CharT >
    > struct ctype_byname {
    > ctype_byname();
    > };
    >
    >
    > template < >
    > ctype_byname<char>::ctype_byname<char>();
    >
    > This code compiles with GCC 3.4.4, Sun CC 5.8, and MSVC 7.1. It fails
    > to compile with GCC 4.1.1, Intel CC 9.1, and Comeau's online compiler.
    >
    > So... who's got it right?
    >
    > My hunch from the fact that GCC used to accept it and now doesn't, plus
    > the fact that Comeau rejects it, is that it's probably not legal, but
    > can anyone verify this?


    The code is close to legal, but not quite: the constructor that you try to
    specialize is not a member template. Thus, you need to lose the second
    template parameter:

    template <class CharT >
    struct ctype_byname {
    ctype_byname();
    };

    template < >
    ctype_byname<char>::ctype_byname();



    [snip]


    Best

    Kai-Uwe Bux
     
    Kai-Uwe Bux, Dec 5, 2006
    #2
    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. Roedy Green

    Nested Class Language Lawyers

    Roedy Green, Aug 24, 2005, in forum: Java
    Replies:
    9
    Views:
    364
    Tor Iver Wilhelmsen
    Aug 29, 2005
  2. Michele Simionato

    iterable terminology (for language lawyers)

    Michele Simionato, Mar 16, 2005, in forum: Python
    Replies:
    4
    Views:
    448
    Raymond Hettinger
    Mar 16, 2005
  3. Kenny McCormack

    One for the language lawyers

    Kenny McCormack, Jun 9, 2008, in forum: C Programming
    Replies:
    11
    Views:
    466
    Serve Lau
    Jun 10, 2008
  4. Replies:
    28
    Views:
    1,213
  5. Replies:
    6
    Views:
    117
Loading...

Share This Page