Boost1.47フェニックスを使用するVisualStudio2008 C ++ 03アプリケーションがあります(更新:1.49も使用)。リストから要素を削除するboost::functionを定義したいと思います。例えば:
#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;
}
しかし、定義で一連のコンパイラエラーが発生しRemoveFromList
ます。
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
同様の関数はAddToList
きれいにコンパイルされます:
boost::function< void( int ) > AddToList = bp::push_back( bp::ref( a ), bpa::arg1 );
これも正しく機能します(ただし、エレガントさははるかに劣ります)。
boost::function< void( int ) > RemoveFromList = bp::bind( &std::remove< std::list< int >::iterator, int >, a.begin(), a.end(), bpa::arg1 );
この関数を実装する正しい方法は何ですか?
ありがとう