转换元组类型
所以我是提升 MPL 的新手,我不知道如何将它与标准类型一起使用。
我想要一个隐藏这种类型的元函数:
std::tuple<T0, T1, ..., TN>
变成这样:
std::tuple<
std::function<T0(std::tuple<T0, T1, ...>, std::tuple<T0, T1, ...>)>,
std::function<T1(std::tuple<T0, T1, ...>, std::tuple<T0, T1, ...>)>,
...,
std::function<TN(...)>
>
这似乎可以用 transform,但我想要一个元组类型,而不是类型向量。 (它实际上不必使用 MPL,但我想它会更短?)
背景:目前我使用完全泛型类型,并且如果使用错误,就会依赖所有的地狱,但我想计算 TupleOfFunctions< /code> 以获得正确的错误。
template<class TupleOfValues, class TupleOfFunctions>
void f(TupleOfValues v, TupleOfFunctions fun)
So I'm new to boost MPL, and I don't know how to use it with standard types.
I want a metafunction that coverts this type:
std::tuple<T0, T1, ..., TN>
Into this:
std::tuple<
std::function<T0(std::tuple<T0, T1, ...>, std::tuple<T0, T1, ...>)>,
std::function<T1(std::tuple<T0, T1, ...>, std::tuple<T0, T1, ...>)>,
...,
std::function<TN(...)>
>
and it seems like this could be done with transform, but I want to have a tuple-type, not a vector of types. (It doesn't have to use MPL actually, but I guess it would be shorter?)
Background: currently I use totally generic types and rely on all hell breaking loose if used wrong, but I want to calculate the TupleOfFunctions
to get a proper error.
template<class TupleOfValues, class TupleOfFunctions>
void f(TupleOfValues v, TupleOfFunctions fun)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面的怎么样?
How about the following?