Boost logo

Boost Users :

Subject: Re: [Boost-users] [phoenix] A simple lambda func as boost::function
From: Richard Vock (vock_at_[hidden])
Date: 2009-12-14 20:33:24


> Please don't top post.

Yepp - already found out and hated me for that
(if there would be any edit buttons..), so -
sorry for that.

> This works for me and I think it is what you are after.
> Am I missing something? (btw ... notice that the int in
> the function sig is by value ... not reference)
>
> --------------------------------
>
> #include <iostream>
> #include <boost/spirit/include/phoenix.hpp>
> #include <boost/function.hpp>
>
> void my_func( boost::function< void(int) > func )
> {
> for( int i=0; i<5; ++i )
> {
> func( i );
> }
> }
>
> int main()
> {
> using boost::phoenix::arg_names::arg1;
>
> my_func( (std::cout << arg1 << '\n') );
>
> return 0;
> }

This is very interesting, since exactly this code won't
compile with my setup (error message looks very close to
the one I supplied in my second post):
g++ (GCC) 4.4.2
BOOST_VERSION 103900
BOOST_PHOENIX_VERSION 0x2000 // 2.0.0


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