c++ - Why am I getting "error: type name is not allowed" with these spaghetti templates? -
this question has answer here:
i have following code bit of "spaghetti" of templates:
template <typename a, typename b, typename... args> class c { /*... */ bar& getbar() { /* ... */ } public: template <typename u> static void foo() { a = geta<u>(); baz& bar = getbar(); bar.frob<u>(a); /* @@@ */ } /*... */ } /* no template */ class d : public c<somea, d, const somee&> { /* ... */ } /* no template */ class f : public d { /* ... */}
and when try compile function following statement:
d::foo<f>();
i error type name not allowed
, on line marked @@@
. why getting that? know when try call function type name, doesn't i'm doing here.
it's classic template ambiguity, unfortunately hard notice if don't know it. answer: need to write bar.template frob<u>(a);
reason: see this q&a.
Comments
Post a Comment