12 Jun 2012 16:42
[Phoenix] using container algorithms
Paul Heil <paul.heil <at> gmail.com>
2012-06-12 14:42:47 GMT
2012-06-12 14:42:47 GMT
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 80Error 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 mailing list Boost-users <at> lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
RSS Feed