1

_pimpl->_connectionsstd::mapなので、その要素はPredicate を使用して不要な値を除外しstd::pair<KeyType, gcl::SectionConnectionT*>たいと考えています。gcl::SectionConnectionT::NotConnectedTo(r)しかし、私が使用する場合

std::remove_copy_if(it_pair.first, it_pair.second, std::back_inserter(sectionConnections), gcl::SectionConnectionT::NotConnectedTo(r));

pairをベクターに挿入しようとします。しかし、ベクトルはタイプ<gcl::SectionConnectionT*>のものです いくつかのグーグル検索transform_iteratorで、理解する方法が理解できないものにたどり着きました。こんな感じで使いました。しかし、コンパイルエラーが発生しますS

std::pair<CollectionT::iterator, CollectionT::iterator> it_pair = _pimpl->_connections.equal_range(l);
std::vector<gcl::SectionConnectionT*> sectionConnections;
std::remove_copy_if(it_pair.first, it_pair.second, boost::make_transform_iterator(std::back_inserter(sectionConnections), util::shorthand::pair_second()), gcl::SectionConnectionT::NotConnectedTo(r));
4

1 に答える 1

1

Boost.Iterator ライブラリは の戻り値の型を推定できない可能性が高いuntil::shorthand::pair_second::operator()(CollectionT::value_type&) constため、返される値は、 (出力反復子)transform_iteratorの 3 番目のパラメーターに使用する必要があるため、書き込み可能な左辺値反復子の概念をモデル化していません。std::remove_copy_if

ただし、次のように動作します。

//#include <boost/lambda/bind.hpp>
//#include <boost/lambda/lambda.hpp>
//#include <boost/range/adaptor/map.hpp>
//#include <boost/range/algorithm/remove_copy_if.hpp>

//namespace gcl {
//struct SectionConnectionT {
//    bool NotConnectedTo(RType r) const;
//    // ...
//};
//}

boost::remove_copy_if(it_pair | boost::adaptors::map_values,
    std::back_inserter(sectionConnections),
    boost::lambda::bind(&gcl::SectionConnectionT::NotConnectedTo, boost::lambda::_1, r));
于 2012-08-19T22:01:51.877 に答える