Witam,
Załóżmy taki kod:
template
class Foo {
template
void bar() {};
};
template
template <>
void Foo::bar() {}
Czyli chcę specjalizować metodę w klasie szablonowej, ale g++ zarówno 4.4 jak i 4.5 wyrzuca błąd
sample.cpp:8: error: invalid explicit specialization before ‘>’ token
sample.cpp:8: error: enclosing class templates are not explicitly specialized
sample.cpp:9: error: template-id ‘bar’ for ‘void Foo::bar()’ does not match any template declaration
Dodam, że specjalizację zarówno klasy jak i metody “łyka” bez błędów:
template <>
template <>
void Foo::bar() {}
Rodzi się więc pytanie: czy ja robię coś źle, czy to niedoskonałość g++?