Boost logo

Boost Users :

From: gast128 (gast128_at_[hidden])
Date: 2007-06-26 04:37:50


Mojmir Svoboda <mojmir.svoboda <at> logicacmg.com> writes:

I was intrigued by this problem, but I couldn't solve it myself. I think it
has to do with the tuple (user defined types, overloaded operator<<, Bll).

consider:

typedef int value_t;
typedef std::vector<value_t> vect_t;
typedef std::pair<value_t, value_t> value_t_pair;
typedef std::vector<value_t_pair> vect2_t;

value_t make_value_t (value_t v) { return v; }
value_t_pair make_value_t_pair(value_t v) { return std::make_pair(v, v); }

std::ostream& operator<<(std::ostream& ros, const value_t_pair&)
{
   return ros;
}

void Foo()
{
   vect_t vec;
 
   //compiles
   std::for_each(vec.begin, vec.end(),
                 std::cout << boost::lambda::bind(&make_value_t,
boost::lambda::_1));

   //does not compile
   std::for_each(vec.begin, vec.end(),
                 std::cout << boost::lambda::bind(&make_value_t_pair,
boost::lambda::_1));

   //does also not compile
   std::for_each(vec.begin, vec.end(),
                 std::cout << boost::lambda::bind<value_t_pair>
(&make_value_t_pair, boost::lambda::_1));
}

But maybe a Bll guru can give a better answer.


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