dumb0
dumb0

Reputation: 337

Template Template argument not in scope

Within this snippet of code...

template<template <unsigned int R,class T,class...Args> class F,typename...G>
class testclass{
protected:
    F<R,T,Args...> f;
};

g++ insists R,T and Args... are not declared in the scope of member variable f. What is the proper syntax?

Thanks!

Upvotes: 0

Views: 169

Answers (1)

David G
David G

Reputation: 96845

You're only allowed to name the arguments of a template-template parameter as a formality, you can't actually use them anywhere. However, you can access the arguments by specializing your class:

template <class F, typename... G>
class testclass;

template <template <unsigned int, class...> class F, unsigned int R, class T,
          class... Args, class... G>
class testclass<F<R, T, Args...>, G...>
{
protected:
    F<R, T, Args...> f;
};

T can actually be replaced with Args... unless you need it specifically.

Upvotes: 3

Related Questions