10 #ifndef META_UTIL_MAPPING_H_
11 #define META_UTIL_MAPPING_H_
31 template <
class Key,
class Value,
class... Args,
32 template <
class,
class,
class...>
class Map>
33 Value safe_at(
const Map<Key, Value, Args...>& map,
const Key& key)
35 auto it = map.find(key);
46 template <
class Key,
class Value>
47 void save_mapping(
const util::invertible_map<Key, Value>& map,
50 std::ofstream outfile{filename};
52 outfile << p.first <<
" " << p.second <<
"\n";
62 void save_mapping(
const std::vector<T>& vec,
const std::string& filename)
64 std::ofstream outfile{filename};
73 template <
class Key,
class Value>
74 void load_mapping(util::invertible_map<Key, Value>& map,
75 const std::string& filename)
77 std::ifstream input{filename};
80 while ((input >> k) && (input >> v))
81 map.insert(std::make_pair(k, v));
90 void load_mapping(std::vector<T>& vec,
const std::string& filename)
92 std::ifstream input{filename};