次の機能に問題があります。
typedef std::tr1::shared_ptr<Island> Island_sp_t;
typedef map<string, Island_sp_t>::value_type island_map_pair;
std::map<std::string, Island_sp_t> Island_ptr_map;
void Model::save_all(ostream& out)
{
for_each(Island_ptr_map.begin(), Island_ptr_map.end(), bind(&Island::save,
bind<Island_sp_t>(&island_map_pair::second, _1), ref(out)));
}
私のIsland::save
機能は次のようになります
virtual void save(std::ostream& out) const;
マップでバインドを使用するためのこの形式は、これまでのところうまくいきましたが、この特定のケースでのみ、g++ 4.1.2 で次のフラグを使用して次のエラーが発生します。
g++ -c Pedantic -ansi -Wall
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/tr1/bind_iterate.h: In member function ‘typename std::tr1::result_of<_Functor ()(typename std::tr1::result_of<std::tr1::_Mu<_T1, std::tr1::is_bind_expression<_T1>::value, (std::tr1::is_placeholder<_T1>::value > 0)> ()(_T1, std::tr1::tuple<_U1, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass>)>::type, typename std::tr1::result_of<std::tr1::_Mu<_T1, std::tr1::is_bind_expression<_T1>::value, (std::tr1::is_placeholder<_T1>::value > 0)> ()(_T2, std::tr1::tuple<_U1, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass>)>::type)>::type std::tr1::_Bind<_Functor ()(_T1,
_T2)>::operator()(_U1&) [with _U1 = std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char>
>, std::tr1::shared_ptr<Island> >, _Functor = std::tr1::_Mem_fn<void (Island::*)(std::ostream&)const>, _T1 = std::tr1::_Bind_result<std::tr1::shared_ptr<Island>, std::tr1::_Mem_fn<std::tr1::shared_ptr<Island> std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char>
>, std::tr1::shared_ptr<Island> >::*> ()(std::tr1::_Placeholder<1>)>, _T2 = std::tr1::reference_wrapper<std::basic_ostream<char, std::char_traits<char> > >]’: /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:159: instantiated from ‘_Function std::for_each(_InputIterator,
_InputIterator, _Function) [with _InputIterator = std::_Rb_tree_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::tr1::shared_ptr<Island> > >, _Function = std::tr1::_Bind<std::tr1::_Mem_fn<void (Island::*)(std::ostream&)const> ()(std::tr1::_Bind_result<std::tr1::shared_ptr<Island>, std::tr1::_Mem_fn<std::tr1::shared_ptr<Island> std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char>
>, std::tr1::shared_ptr<Island> >::*> ()(std::tr1::_Placeholder<1>)>, std::tr1::reference_wrapper<std::basic_ostream<char, std::char_traits<char> > >)>]’ Model.cpp:179: instantiated from here /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/tr1/bind_iterate.h:45: error: no match for call to ‘(std::tr1::_Mem_fn<void (Island::*)(std::ostream&)const>) (std::tr1::shared_ptr<Island>, std::basic_ostream<char, std::char_traits<char> >&)’ /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/tr1/functional_iterate.h:261: note: candidates are: _Res std::tr1::_Mem_fn<_Res (_Class::*)(_T1)const>::operator()(const _Class&, _T1) const [with
_Res = void, _Class = Island, _T1 = std::ostream&] /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/tr1/functional_iterate.h:267: note: _Res std::tr1::_Mem_fn<_Res (_Class::*)(_T1)const>::operator()(const _Class*, _T1) const [with
_Res = void, _Class = Island, _T1 = std::ostream&] /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/tr1/functional_iterate.h:274: note: _Res std::tr1::_Mem_fn<_Res (_Class::*)(_T1)const>::operator()(_Tp&, _T1) const [with _Tp = std::tr1::shared_ptr<Island>, _Res = void, _Class = Island, _T1 = std::ostream&] /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/tr1/bind_iterate.h:45: error: return-statement with a value, in function returning 'void' make: *** [Model.o] Error 1
functional_iterate.h:274
すべてのタイプが候補とうまく一致しているように見えるため、このエラーに非常に混乱しています。私が欠けているものに関するアイデアはありますか?