|
Boost Users : |
Subject: Re: [Boost-users] [phoenix] Using with Boost.Function.
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2012-11-02 05:30:10
Nice try, and thanks for correcting my missing bind invocation, but still
no tomato!
#include <boost/function.hpp>
#include <boost/phoenix/core.hpp>
#include <boost/phoenix/operator.hpp>
#include <boost/phoenix/bind/bind_member_variable.hpp>
#include <boost/phoenix/bind/bind_function.hpp>
#include <boost/phoenix/bind/bind_function_object.hpp>
#include <boost/function.hpp>
#include <list>
struct S { int i; };
bool pred_fn( int i, int j ) { return i >= j; }
void f( std::list<S> & l, int i )
{
using boost::phoenix::arg_names::_1;
using boost::phoenix::arg_names::_2;
boost::function<bool( int, int )> pred_obj = _1 >= _2;
// OK
l.remove_if( bind( & S::i, _1 ) >= i );
// OK
l.remove_if( bind( pred_fn, bind( & S::i, _1 ), i ) );
// Not OK.
l.remove_if( bind( pred_obj, bind( & S::i, _1 ), i ) );
}
Results in this error...
In file included from
/home/rjones/local/gcc-4.6.2/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../include/c++/4.6.2/list:65:0,
from function.cpp:8:
/home/rjones/local/gcc-4.6.2/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../include/c++/4.6.2/bits/list.tcc:
In member function void std::list<_Tp, _Alloc>::remove_if(_Predicate)
[with _Predicate = std::_Bind<boost::function<bool(int,
int)>(boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::phoenix::detail::tag::function_eval,
boost::proto::argsns_::list2<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::phoenix::detail::member_variable<int,
int S::*> >, 0l>,
boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::phoenix::argument<1> >, 0l> > >, 2l> >,
int)>, _Tp = S, _Alloc = std::allocator<S>]:
function.cpp:28:58: instantiated from here
/home/rjones/local/gcc-4.6.2/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../include/c++/4.6.2/bits/list.tcc:401:6:
error: no match for call to (std::_Bind<boost::function<bool(int,
int)>(boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::phoenix::detail::tag::function_eval,
boost::proto::argsns_::list2<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::phoenix::detail::member_variable<int,
int S::*> >, 0l>,
boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::phoenix::argument<1> >, 0l> > >, 2l> >,
int)>) (S&)
/home/rjones/local/gcc-4.6.2/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../include/c++/4.6.2/functional:1130:11:
note: candidates are:
/home/rjones/local/gcc-4.6.2/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../include/c++/4.6.2/functional:1201:2:
note: template<class ... _Args, class _Result> _Result
std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) [with _Args
= {_Args ...}, _Result = _Result, _Functor = boost::function<bool(int,
int)>, _Bound_args =
{boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::phoenix::detail::tag::function_eval,
boost::proto::argsns_::list2<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::phoenix::detail::member_variable<int,
int S::*> >, 0l>,
boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::phoenix::argument<1> >, 0l> > >, 2l> >,
int}]
/home/rjones/local/gcc-4.6.2/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../include/c++/4.6.2/functional:1215:2:
note: template<class ... _Args, class _Result> _Result
std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const [with
_Args = {_Args ...}, _Result = _Result, _Functor =
boost::function<bool(int, int)>, _Bound_args =
{boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::phoenix::detail::tag::function_eval,
boost::proto::argsns_::list2<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::phoenix::detail::member_variable<int,
int S::*> >, 0l>,
boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::phoenix::argument<1> >, 0l> > >, 2l> >,
int}]
/home/rjones/local/gcc-4.6.2/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../include/c++/4.6.2/functional:1229:2:
note: template<class ... _Args, class _Result> _Result
std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) volatile
[with _Args = {_Args ...}, _Result = _Result, _Functor =
boost::function<bool(int, int)>, _Bound_args =
{boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::phoenix::detail::tag::function_eval,
boost::proto::argsns_::list2<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::phoenix::detail::member_variable<int,
int S::*> >, 0l>,
boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::phoenix::argument<1> >, 0l> > >, 2l> >,
int}]
/home/rjones/local/gcc-4.6.2/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../include/c++/4.6.2/functional:1243:2:
note: template<class ... _Args, class _Result> _Result
std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const
volatile [with _Args = {_Args ...}, _Result = _Result, _Functor =
boost::function<bool(int, int)>, _Bound_args =
{boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::phoenix::detail::tag::function_eval,
boost::proto::argsns_::list2<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::phoenix::detail::member_variable<int,
int S::*> >, 0l>,
boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::phoenix::argument<1> >, 0l> > >, 2l> >,
int}]
gmake: *** [function.o] Error 1
Thoughts?
Thx, Rob.
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