Answers for "c++ print keys of map"

C++
0

prints all the keys and values in a map c++

for (auto x : m) {
cout << x.first << " " << x.second << "n";
}
Posted by: Guest on April-13-2021
1

c++ get map keys

template<typename TK, typename TV>
std::vector<TK> extract_keys(std::map<TK, TV> const& input_map) {
  std::vector<TK> retval;
  for (auto const& element : input_map) {
    retval.push_back(element.first);
  }
  return retval;
}
Posted by: Guest on March-15-2021

Browse Popular Code Answers by Language