简体   繁体   中英

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?

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();
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM