Stefano
Stefano

Reputation: 3259

Use template template parameter as return type of class function

I have created the following template struct where the second template parameter is a template template parameter. I would like to use it as return type of a function of sudden struct.

template<typename T, template<typename /*T*/, typename /*U*/> typename V>
struct MyStruct
{
   V myFunction();
}

I tried returning V, but it obviously doesn't work. I then tried returning V<T, U> but it doesn't work too. Should I declare the U parameter as the third template parameter of MyStruct or is there any other way to do what I want to do?

Upvotes: 0

Views: 156

Answers (1)

DimChtz
DimChtz

Reputation: 4313

You re missing the argument list of V. However, you can't use V<T, U> myFunction(); as you said. If you want to use U or anything else you need to add it. For example:

template<typename T, template<typename /*T*/, typename /*U*/> typename V, typename P>
struct MyStruct {
    V<T, P> myFunction();
};

Upvotes: 1

Related Questions