c++ - "ambiguating new declaration" error for a templated method in a templated class -


i have written following earth-shattering application:

class somea { }; class someb { }; class somec { };  template <typename a, typename b, typename... cs> class foo { public:     template <typename u> static void bar(); };  template <typename u> void foo<somea, someb, somec>::bar() { };  int main() { return 0; } 

when compile (gcc 4.9.3 -std=c++11), following error:

a.cpp:10:36: error: ambiguating new declaration of ‘static void foo<somea, someb, somec>::bar()’  void foo<somea, someb, somec>::bar() { };                                     ^ a.cpp:6:36: note: old declaration ‘static void foo<a, b, cs>::bar() [with u = u; = somea; b = someb; cs = {somec}]’   template <typename u> static void bar();                                     ^ 

why "ambiguating declaration", , how else can implement bar us specific instantiation of foo?

with clang 3.6.2, error:

a.cpp:9:1: error: template parameter list matching non-templated nested type 'foo<somea, someb, somec>' should empty ('template<>') template <typename u> ^        ~~~~~~~~~~~~ 

i don't either. how supposed template on u if clang wants empty parameter list?

no idea ambiguating new declaration means, you're specializing enclosing class template foo, need indicate empty template parameter list

template <> template <typename u> void foo<somea, someb, somec>::bar() { } 

live demo


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -