如何从元组中提取类型列表的struct/class
我想在类中使用静态方法,该方法在std :: tuple< t1,t2,t3,...>
中获取类型列表。我不想使用std :: tuple< ...>
我想拥有< ...>
。 如何实现示例struct x
导致ts ==< t1,t2,t3,...>
template<template <typename...> typename TL, typename... Ts>
struct x {
static void test() {
// expecting Ts == <int, char, float, double> (without std::tuple<>)
std::cout << __PRETTY_FUNCTION__ << '\n';
}
};
using types = std::tuple<int, char, float, double>;
x<types>::test();
参见 godbolt上的示例
I want to use a static method in a class that gets a type list in the form std::tuple<T1, T2, T3,...>
. Instead of working with std::tuple<...>
I want to have <...>
.
How to implement example struct x
resulting in Ts == <T1, T2, T3,...>
template<template <typename...> typename TL, typename... Ts>
struct x {
static void test() {
// expecting Ts == <int, char, float, double> (without std::tuple<>)
std::cout << __PRETTY_FUNCTION__ << '\n';
}
};
using types = std::tuple<int, char, float, double>;
x<types>::test();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,您正在寻找模板专业化。
类似的东西
It seems to me that you're looking for template specialization.
Something as