
On Thu, Apr 12, 2012 at 6:13 AM, Mathias Gaunard < mathias.gaunard@ens-lyon.org> wrote:
On 12/04/12 10:36, Robert Jones wrote:
*** Not Tested or Compiled ***
#include<boost/range.hpp> #include<boost/range/adaptors/**filtered.hpp> // ... and maybe some other range headers #include<boost/bind.hpp>
for_each( mystrings | boost::adaptors::filtered( boost::bind( get<0>, _1 ) == 10 ), yourAction );
You probably can't take the address of get<0>.
Also, you could remove the dependence on filtered by using find_if instead of for_each.
How would I use find_if() for this? I tried this: using namespace boost::phoenix; using namespace boost::phoenix::arg_names; using namespace boost::range; ErrorStringMap::const_iterator it = find_if( g_error_info, at_c<0>(_1) == error_code ); if( it != g_error_info.end() ) { return *it; } However I haven't used Boost.Range before and I don't see any documentation in Boost.Range about the binary-or operator being used with the algorithms. My above code won't compile, apparently find_if() won't take an actor as a predicate. No idea how to convert it though.