Boost logo

Boost Users :

Subject: [Boost-users] [Phoenix] using container algorithms
From: Paul Heil (paul.heil_at_[hidden])
Date: 2012-06-12 10:42:47


have a Visual Studio 2008 C++03 application using boost 1.49 phoenix. I
would like to define a boost::function to remove an element from a list.
For example:

#include <boost/phoenix.hpp>
#include <boost/function.hpp>
#include <boost/phoenix/stl/container.hpp>
#include <boost/phoenix/stl/algorithm/transformation.hpp>
#include <algorithm>
#include <list>

int main()
{
    namespace bp = boost::phoenix;
    namespace bpa = boost::phoenix::arg_names;
    std::list< int > a;
    boost::function< void( int ) > RemoveFromList = bp::remove(
bp::ref( a ), bpa::arg1 );
    return 0;
}

but I get a series of compiler errors on my RemoveFromList definition.

Error 1 error C2504: 'boost::phoenix::impl::remove::result<Sig>' :
base class undefined \boost\utility\result_of.hpp 80
Error 2 error C2039: 'type' : is not a member of
'boost::result_of<F>'
\boost\phoenix\core\detail\preprocessed\function_eval_10.hpp 121
Error 3 error C2146: syntax error : missing ';' before identifier
'type' \boost\phoenix\core\detail\preprocessed\function_eval_10.hpp
122
Error 4 error C4430: missing type specifier - int assumed. Note: C++
does not support default-int
\boost\phoenix\core\detail\preprocessed\function_eval_10.hpp 122
Error 5 error C2602:
'boost::phoenix::detail::function_eval::result<Sig>::type' is not a
member of a base class of
'boost::phoenix::detail::function_eval::result<Sig>'
\boost\phoenix\core\detail\preprocessed\function_eval_10.hpp 122
Error 6 error C2868:
'boost::phoenix::detail::function_eval::result<Sig>::type' : illegal
syntax for using-declaration; expected qualified-name
\boost\phoenix\core\detail\preprocessed\function_eval_10.hpp 122

A similar function AddToList compiles cleanly:

boost::function< void( int ) > AddToList = bp::push_back( bp::ref( a
), bpa::arg1 );

This also works correctly (but is much less elegant):

boost::function< void( int ) > RemoveFromList = bp::bind(
&std::remove< std::list< int >::iterator, int >, a.begin(), a.end(),
bpa::arg1 );

What is the correct way to use the boost.phoenix.remove function?

Thanks



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