Posts

Showing posts from January 9, 2019

std::map::size_type for a std::map whose value_type is its own size_type

Image
up vote 4 down vote favorite 2 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