0

I have the following code with a bit of a "spaghetti" of templates:

template <typename A, typename B, typename... Args>
class C {
    /*... */
    Bar& getBar() { /* ... */ }
public:
    template <typename U>
    static void Foo() {
        A 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 I try to compile a function with the following statement:

D::Foo<F>();

I get the error type name is not allowed, on the line marked @@@. Why would I be getting that? I know you get it when you try to call a function with a type name, but it doesn't look like I'm doing it here.

einpoklum
  • 118,144
  • 57
  • 340
  • 684

1 Answers1

3

It's a classic template ambiguity, that unfortunately is hard to notice if you don't know about it. Answer: you need to to write bar.template frob<U>(a); Reason: see this Q&A.

Community
  • 1
  • 1
TemplateRex
  • 69,038
  • 19
  • 164
  • 304