Equivalent to "typename" to indicate that the dependent name is indeed a "template template parameter"

We have reduced some of the code; we cannot find the correct syntax for a minimal example.

Suppose the following definitions (do not worry about why;)

template <class>
class Element
{};

template <template <class> class>
class Client
{};

template <class>
struct TemplatedProvider
{
    template <class T>
    using element_template = Element<T>;
};

Now, using C ++ 11, we can use a template template or a type alias template to create an instance of the template Client. The following function compiles just fine:

void fun()
{
    Client<Provider::element_template> client;
    Client<TemplatedProvider<int>::element_template> clientBis;
}

But we cannot find the correct syntax in the following case, when the template argument assigned Clientis a dependent name:

template <class T>
void templatedFun()
{
    Client<TemplatedProvider<T>::element_template> client;
}

Clang (verified since 3.6) emits the following compilation error:

template argument for template template parameter must be a class template or type alias template

Can this syntax be fixed?

+4
2

template:

template <class T>
void templatedFun()
{
    Client<TemplatedProvider<T>::template element_template> client;
}

. template typename.

+4

:

template <class T>
void templatedFun()
{
    Client<TemplatedProvider<T>::template element_template> client;
}
+9

Source: https://habr.com/ru/post/1613670/


All Articles