help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Template member function specialization


From: martines
Subject: Template member function specialization
Date: Fri, 25 Feb 2005 01:01:50 +0100

Hi all,

This code gives me an error on gcc 3.4.2:

struct Simple {
    template <class T>
        void fun() {}
    template <>               // *)
        void fun<int>() {}    // **)
};

*)  error: invalid explicit specialization before '>' token
    error: explicit specialization in non-namespace scope `struct Simple'
**) error: invalid member function declaration

However following code compiles:

template <class T>
    void fun() {}
template <>
    void fun<int>() {}

Can anybody explain what is wrong with the first code and what is the 
rationale behind this error? And how to fix it so the code could compile on 
g++, VC6 and VC7.1?

TIA,

martines




reply via email to

[Prev in Thread] Current Thread [Next in Thread]