Let's go lambda
given: multimap M
requested: vector
(of all values in M with a specific key 'a'.)
method:
std::pair aRange = M.equal_range('a')
std::vector aVector;
std::transform(aRange.first, aRange.second,std::back_inserter(aVector), [](std::pair element){return element.second;});
System environment:
- compiler: gcc (Ubuntu 5.3.1-14ubuntu2.1) 5.3.1 20160413 (with -std=c++11)
- os: ubuntu 16.04
Code example:
#include
#include
#include