[英]Use the template parameter type of derived as return type for function (CRTP)?
[英]Use template template parameter as return type of class function
我創建了以下模板結構,其中第二個模板參數是模板模板參數。 我想將其用作突發結構函數的返回類型。
template<typename T, template<typename /*T*/, typename /*U*/> typename V>
struct MyStruct
{
V myFunction();
}
我嘗試返回V
,但是顯然不起作用。 然后,我嘗試返回V<T, U>
但是它也不起作用。 我應該將U
參數聲明為MyStruct
的第三個模板參數,還是有其他方法可以做我想做的事情?
您缺少V
的參數列表。 但是,不能使用V<T, U> myFunction();
如你所說。 如果要使用U
或其他任何內容,則需要添加它。 例如:
template<typename T, template<typename /*T*/, typename /*U*/> typename V, typename P>
struct MyStruct {
V<T, P> myFunction();
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.