jeudi 3 décembre 2015

Refer to own type for a template template parameter

Here's the simplest case of what I'm trying to do:

template <template <typename...> class Wrapper>
struct WrapperTraits { };

template <typename... Whatever>
struct Foo {
private:
    // I want Foo here to refer to the template, and not the current
    // concrete type (which is injected into the namespace by default)
    using Traits = WrapperTraits<Foo>;
};

int main()
{
    return 0;
}

And here's the error on clang 3.6 (it compiles fine on gcc 4.8 and 5.2):

error: template argument for template template parameter must be a class template or type alias template
using Traits = WrapperTraits<Foo>;
^
1 error generated.
Compilation failed

Here is the example in question on godbolt: https://goo.gl/cSx6QR

Thanks for your help!

Aucun commentaire:

Enregistrer un commentaire