Boost logo

Boost Users :

Subject: [Boost-users] [phoenix] [range] I think I'm missing a couple things w/ these libs
From: Jake Brownson (jake_at_[hidden])
Date: 2011-04-06 16:50:26


I love the ideas behind these libs, but I think I need to figure out a
bit more before I can use them.

Here's an example that models what I'm trying to do for real as an
experiment w/ using phoenix and range. I can't quite get it to build.
I think I'm really close. I tried it w/ lambda before I found phoenix
and I had to do some ret<> things to get past some errors, but I'm not
sure what the equivalent in phoenix is, or if I should really need
them.

Also, I think there should be a way to instantiate a vector directly
from a range w/o having to use begin() and end() somehow, but I can't
find it.

I've tried various approaches with <something> including
transformed_range<> and any_range<> and haven't gotten them to work.
The transformed line gives me errors complaining about missing
result_type, iterator_category, value_type, difference_type, pointer,
reference.

I'm using GCC 4.2 on OS X

Thanks!

----
#include <boost/range/adaptor/transformed.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_bind.hpp>
#include <vector>
class A {};
class B { public: A a; };
class C
{
public:
	static B BFromA(const A& a) { return B(); }
};
std::vector<C> CsFromBs(std::vector<B> bs)
{
	<something> cs = bs |
boost::adaptors::transformed(boost::phoenix::bind(&C::BFromA,
boost::phoenix::bind(&B::a, boost::phoenix::arg_names::arg1)));
	return std::vector<C>(boost::begin(cs), boost::end(cs));
}

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