Dav*_*sat 3 c++ templates typelist c++17 std-variant
有没有办法创建一个预定义的类型列表,并在c ++ 17中的std :: variant中使用这些类型?这是我正在尝试做的,它编译,但不能像我希望的那样工作:
template < class ... Types > struct type_list {};
using valid_types = type_list< int16_t, int32_t, int64_t, double, std::string >;
using value_t = std::variant< valid_types >;
Run Code Online (Sandbox Code Playgroud)
单程:
template<class... Types>
std::variant<Types...> as_variant(type_list<Types...>);
using value_t = decltype(as_variant(valid_types{}));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
329 次 |
| 最近记录: |