std::map から特定の要素をベクターにコピーする必要があります。次のループのように動作するはずです。
typedef int First;
typedef void* Second;
std::map<First, Second> map;
// fill map
std::vector<Second> mVec;
for (std::map<First, Second>::const_iterator it = map.begin(); it != map.end(); ++it) {
if (it->first % 2 == 0) {
mVec.push_back (it->second);
}
}
ファンクターの使用を避けたいが、代わりにboost::lambdaを使用したいので、std::copyを使用してみましたが、うまくいきません。
std::copy (map.begin(), map.end(), std::back_inserter(mVec)
bind(&std::map<int, void*>::value_type::first, _1) % 2 == 0);
私はラムダ式が初めてで、それらを正しく使用する方法がわかりません。Google でも StackOverflow でも、有用な結果は得られませんでした。 この質問は似ています