2011-08-23から1日間の記事一覧

Boost.Phoenix で、std::map の remove_if を書いてみた

Boost.Range を思いつく前に書いたボツネタ。 iterator を回して直接、値を削除しています。 Boost.Phoenix に first と second が欲しいですね。 [ソース] #include <boost/phoenix.hpp> #include <boost/typeof/typeof.hpp> #include <map> #include <string> #include <iostream> template<typename T> typename T::first_type first_impl(</typename></iostream></string></map></boost/typeof/typeof.hpp></boost/phoenix.hpp>…

std::map で remove_if をする

いろいろと考えていたんですが Boost.Range の filter でそれっぽく処理することが出来ました。 [ソース] #include <boost/range/algorithm/for_each.hpp> #include <boost/range/adaptor/filtered.hpp> #include <boost/typeof/typeof.hpp> #include <boost/bind.hpp> #include <map> #include <string> #include <iostream> bool over_three(std::pair</iostream></string></map></boost/bind.hpp></boost/typeof/typeof.hpp></boost/range/adaptor/filtered.hpp></boost/range/algorithm/for_each.hpp>