I have a std::map<std::pair<std::string, std::string>, float>
that is taking up too much memory, and in order to use less memory, I've decided to map the unique strings to integers (e.g., std::map<std::string, int>
, where each new unique string is mapped to the current size()
of the map), and use those integer value as pairwise keys to the map, (e.g., std::map<std::pair<int, int>, float>
).
Instead of int
, I want to use std::map::size_type:
using map_index = std::map::size_type;
std::pair<map_index, map_index> key;
Of course, this doesn't compile because I need to supply the argument list for the map:
vector.cc:14:19: error: invalid use of template-name `std::map' without an argument list
using map_index = std::map::size_type;
And this (in theory) is what I'm trying to achieve:
using map_index = std::map<std::string, map_index>::size_type;
which gives the following (expected) compiler error:
vector.cc:15:41: error: `map_index' was not declared in this scope
using map_index = std::map<std::string, map_index>::size_type;
What is the proper way to get the correct std::map::size_type
for a map whose value type is its own size_type
?
Aucun commentaire:
Enregistrer un commentaire