目前,我有一个
variant
属于
map
类型,其中我硬编码键值对的所有变体,例如:
using MapCombinator = std::variant<
std::map<std::string, std::string>,
std::map<std::string, int>,
std::map<int, std::string>,
std::map<int, int>>;
在实际情况中,我需要支持所有基本类型的键值对,除了
std::string
。这就是为什么我只想指定一个类型的元组,更像这样:
using KVTypes = std::tuple<std::string, int, etc...>;
using MapCombinator = MapCombinatorImpl::type;
哪里
MapCombinatorImpl
包含创建最终变量类型的模板元编程逻辑。我期待这样的事情:
template<typename... SupportedTypes>
struct MapCombinatorImpl {
typedef ??? type;
};
我不想为此使用宏,如果模板元编程太复杂,我将只支持基本类型的可管理子集。
欢迎使用模板元编程实现。