読者です 読者をやめる 読者になる 読者になる

STL 難い

C++

give up.


// 本当は status は違うクラスの内部クラス
class status {
public:
void tick() { /* do something */ }
};

hash_map<int, status> node_status;

for_each(
node_status.begin(),
node_status.end(),
compose1(
mem_fun(&status::tick),
select2nd<
hash_map<int, status>::value_type
>()
)
);

/usr/include/stlport/stl/_function.h: In member function ‘typename stlp_std::unary_function::result_type stlp_std::unary_compose<_Operation1, _Operation2>::operator()(typename stlp_std::__call_traits::argument_type>::param_type) const [with _Operation1 = stlp_std::mem_fun_t, _Operation2 = stlp_std::select2nd >]’:

/usr/include/stlport/stl/_algo.h|61| instantiated from ‘_Function stlp_std::for_each(_InputIter, _InputIter, _Function) [with _InputIter = stlp_priv::_Ht_iterator, stlp_std::_Nonconst_traits > >, stlp_priv::_NonLocalHashMapTraitsT > >, _Function = stlp_std::unary_compose, stlp_std::select2nd > >]’
topology_view.cpp|80| instantiated from here
/usr/include/stlport/stl/_function.h|226| error: no match for call to ‘(const stlp_std::mem_fun_t) (const hoge::MyTopologyView::status&)’
/usr/include/stlport/stl/_function_adaptors.h|416| note: candidates are: _Ret stlp_std::mem_fun_t<_Ret, _Tp>::operator()(_Tp*) const [with _Ret = void, _Tp = hoge::MyTopologyView::status]
/usr/include/stlport/stl/_function.h|226| error: return-statement with a value, in function returning 'void'