I need a type to store variables of various types, including vectors and maps with this type, how can I do this in C++17?
The example below shows what I need to get, but it does not work.
#include <map>
#include <variant>
#include <vector>
template<class V>
using var_type_base = std::variant<bool, int, double, std::string, std::vector<V>, std::map<std::string, V>>;
using var_type = var_type_base<var_type_base>;
int main()
{
std::map<std::string, int> m;
var_type v = m;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire