Boost logo

Boost Users :

Subject: [Boost-users] boost any_range
From: tolik levchik (endight_at_[hidden])
Date: 2012-07-12 09:05:24


Is it possible the commented below condition. With regular ranges i make as
many 'base()' calls as may adaptors i had applied. Obviously it's
impossible with any_range. So what should i do ?

#include <map>
#define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bind.hpp>
#include <boost/range/any_range.hpp>

struct foo{
int x, y;
};
inline bool is_valid(int x){ return x > 0;}

int main()
{
using namespace boost::adaptors; using boost::bind;
typedef std::map<char, foo> map_t;

typedef const int type;
typedef boost::any_range<
type, boost::forward_traversal_tag,
typename boost::add_reference<type>::type,
std::ptrdiff_t
> forward_range_t;

map_t m;
forward_range_t rng = m | map_values | transformed(bind(&foo::x, _1)); //
note: don't compile without BOOST_RANGE_ENABLE_CONCEPT_ASSERT defined as 0
forward_range_t::const_iterator found = boost::find_if(rng, is_valid);
// found == boost::end(m); how to do it right ?
}



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net