CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2002
    Posts
    11

    Operator template specialization

    [Sorry for posting this accidentally over in the graphics forum. It should be in this forum.]

    Can anyone tell me why the following code compiles under GCC but not with MSVC? MSVC cannot parse the code properly.


    class Foo
    {
    };

    template<typename T1> void operator<<(Foo&, T1){}

    template<> void operator<< <int>(Foo&, int){}

    It says "error C2143: syntax error : missing ';' before '<'" Thus, it is failing to parse the <int> after the << operator. GCC has no problem with it.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449
    an anyone tell me why the following code compiles under GCC but not with MSVC? MSVC cannot parse the code properly.
    That's because VC++ 6.0 is broken. If your template uses anything that is sophisticated, you basically crosss your fingers and hope it compiles with 6.0. Otherwise you need to code a workaround that works with 6.0, or upgrade to VC++ 7.x

    Regards,

    Paul McKenzie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured