【发布时间】:2023-04-06 18:38:01
【问题描述】:
假设我有一个元函数,它需要类型 和 它的参数。如何在不强制函数用户分别提供类型及其参数的情况下做到这一点?
using MyType = SomeType<T1, T2, T3>; // This is the type to pass to the functor
template <typename MyType, typename ... Args>
struct MetaFunction
{
using type = SomeOperation<MyType, Args...>;
}
// I want to be able to call my functor like this:
MetaFunction<MyType>::type;
// but with the above I have to call it like this:
MetaFunction<MyType, T1, T2, T3>::type;
我该怎么做?
【问题讨论】:
-
@dyp。是的!您可以将其发布为答案吗?
标签: c++ templates c++11 template-meta-programming