STLTemplate/STL & EffectiveSTL
compose_f_gx f(gx)) 조립함수객체 어댑터
3DMP
2012. 11. 1. 21:08
emplate<typename OP1,typename OP2>
class compose_f_gx_t : public unary_function< typename OP2::argument_type,typename OP1::result_type>
{
private :
OP1 op1; // op(op2(x)) 를 처리한다
OP2 op2;
public :
compose_f_gx_t(const OP1& o1, const OP2& o2) : op1(o1), op2(o2)
{
}
typename OP2::result_type
operator()(const typename OP2::argument_type& x) const {
return op1(op2(x));
}
};
template<typename OP1,typename OP2>
inline compose_f_gx_t<OP1,OP2> compose_f_gx(const OP1& o1, const OP2& o2){
return compose_f_gx_t<OP1,OP2>(o1,o2);
}
반응형