boost::adaptors::map_values
References
Headers
boost::adaptors::map_values
is available by including
any of the following headers:
boost/range/adaptor/map.hpp
orboost/range/adaptors.hpp
Examples
map_adaptors-pipe.cpp
#include <iostream>
#include <map>
#include <string>
#include <boost/algorithm/string/join.hpp>
#include <boost/range/adaptors.hpp>
const std::map<int, std::string> numbermap = {
std::make_pair(1, "one"),
std::make_pair(2, "two"),
std::make_pair(3, "three"),
};
int main() {
std::cout << "map keys: ";
for (const auto & key : numbermap | boost::adaptors::map_keys) {
std::cout << key << " ";
}
std::cout << std::endl;
std::cout << "map values: "
<< boost::algorithm::join(numbermap | boost::adaptors::map_values, " ")
<< std::endl;
return 0;
}
Output:
map keys: 1 2 3
map values: one two three
Boost Range for Humans
This reference is part of Boost Range for Humans. Click the link to the overview.