Hi Thomas,

You're right, I've just changed the include from boost/bind.hpp to boost/lambda/bind.hpp and now works perfectly.

thank you,

 Mirko





On Thu, Apr 12, 2012 at 11:50, Thomas Heller <thom.heller@googlemail.com> wrote:
On 04/12/2012 11:06 AM, mik wrote:
Hi,

I'm trying to use thew BLL for the first time and I've the following
program:

class Date
{
public:
   Date(long d): _lDate(d) {}
   long getDate() const { return _lDate; }
   [...]
private:
   long _lDate;
};

std::ostream&  operator<<(std::ostream&s, const Date&x)
{
   [...]
}

struct C
{
   C(long d): date(d) {}
   Date date;
};

int main()
{
   const C c(46000);
   std::cout<<  boost::bind(&C::date, boost::lambda::_1)(c)<<  std::endl;

   std::vector<C>  cont(1, C(46000));
   std::for_each(cont.begin(), cont.end(), std::cout<<
boost::bind(&C::date, boost::lambda::_1));

   return 0;
}

The first std::cout is ok. But for the second one nested int the for_each I
get this message error:

error C2679: binary '<<' : no operator found which takes a right-hand
operand of type 'boost::_bi::bind_t<R,F,L>' (or there is no acceptable
conversion)
with
[
   R=const Date&,
   F=boost::_mfi::dm<Date,C>,
   L=boost::_bi::list1<boost::arg<1>>
]
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\ostream(653):
could be 'std::basic_ostream<_Elem,_Traits>  &std::operator
<<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits>  &,const
char *)' [found using argument-dependent lookup]
with
[
   _Elem=char,
   _Traits=std::char_traits<char>
]

Can you help me?

To be honest, I am surprised that the first cout expression works. Boost.Lambda placeholders don't match well with Boost.Bind.
If you meant boost::lambda::bind instead of boost::bind, the for_each should work, assuming you included the header defining the operator
overloads for BLL expressions.
Assuming that you really meant boost::bind, and instead of ::_1 you accidently wrote boost::lambda::_1, you are in trouble. Boost.Bind only
overloads the following operators:  !, ==, !=, <, <=, >, >=, &&, ||. Which is the reason your program didn't compile.
If you have more problems, please provide a complete testcase (i.e. with includes etc.)


Thank you,
    Mirko


**



_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users