diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-06-22 17:53:39 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-06-22 17:53:39 +0900 |
| commit | e791eb9ca334e7746bc0735cebcda09e30fa65df (patch) | |
| tree | 52a501343b31e55a0d71700171599fd94f969580 /src/a2functional.h | |
| parent | 50dcd6394c645fdd9e7fbe879f511888bfa88423 (diff) | |
Cleanup a2functional.h
Remove mem_fun_sh in favor of std::mem_fun. Remove unused functions.
Use std::mem_fn instead of mem_fun_sh
Diffstat (limited to 'src/a2functional.h')
| -rw-r--r-- | src/a2functional.h | 123 |
1 files changed, 0 insertions, 123 deletions
diff --git a/src/a2functional.h b/src/a2functional.h index 871db2de..34b0fda5 100644 --- a/src/a2functional.h +++ b/src/a2functional.h @@ -46,129 +46,6 @@ namespace aria2 { -// mem_fun_t for SharedHandle -template <class ReturnType, typename ClassType> -class mem_fun_sh_t:public std::unary_function< std::shared_ptr<ClassType>, ReturnType> -{ -private: - ReturnType (ClassType::*f)(); - -public: - mem_fun_sh_t(ReturnType (ClassType::*f)()):f(f) {} - - ReturnType operator()(const std::shared_ptr<ClassType>& x) const - { - return (x.get()->*f)(); - } -}; - -// const_mem_fun_t for SharedHandle -template <class ReturnType, typename ClassType> -class const_mem_fun_sh_t:public std::unary_function< std::shared_ptr<ClassType>, ReturnType> -{ -private: - ReturnType (ClassType::*f)() const; - -public: - const_mem_fun_sh_t(ReturnType (ClassType::*f)() const):f(f) {} - - ReturnType operator()(const std::shared_ptr<ClassType>& x) const - { - return (x.get()->*f)(); - } -}; - -template <class ReturnType, typename ClassType> -mem_fun_sh_t<ReturnType, ClassType> -mem_fun_sh(ReturnType (ClassType::*f)()) -{ - return mem_fun_sh_t<ReturnType, ClassType>(f); -}; - -template <class ReturnType, typename ClassType> -const_mem_fun_sh_t<ReturnType, ClassType> -mem_fun_sh(ReturnType (ClassType::*f)() const) -{ - return const_mem_fun_sh_t<ReturnType, ClassType>(f); -}; - -// mem_fun1_t for SharedHandle -template<typename ReturnType, typename ClassType, typename ArgType> -class mem_fun1_sh_t:public std::binary_function<std::shared_ptr<ClassType>, - ArgType, - ReturnType> -{ -private: - ReturnType (ClassType::*f)(ArgType); - -public: - mem_fun1_sh_t(ReturnType (ClassType::*f)(ArgType)):f(f) {} - - ReturnType operator()(const std::shared_ptr<ClassType>& x, ArgType a) const - { - return (x.get()->*f)(a); - } -}; - -template<typename ReturnType, typename ClassType, typename ArgType> -mem_fun1_sh_t<ReturnType, ClassType, ArgType> -mem_fun_sh(ReturnType (ClassType::*f)(ArgType)) -{ - return mem_fun1_sh_t<ReturnType, ClassType, ArgType>(f); -}; - -template<class BinaryOp, class UnaryOp> -class adopt2nd_t:public std::binary_function<typename BinaryOp::first_argument_type, - typename UnaryOp::argument_type, - typename BinaryOp::result_type> { -private: - BinaryOp binaryOp_; - UnaryOp unaryOp_; -public: - adopt2nd_t(const BinaryOp& b, const UnaryOp& u): - binaryOp_(b), unaryOp_(u) {} - - typename BinaryOp::result_type - operator()(const typename BinaryOp::first_argument_type& x, - const typename UnaryOp::argument_type& y) - { - return binaryOp_(x, unaryOp_(y)); - } - -}; - -template <class BinaryOp, class UnaryOp> -inline adopt2nd_t<BinaryOp, UnaryOp> -adopt2nd(const BinaryOp& binaryOp, const UnaryOp& unaryOp) -{ - return adopt2nd_t<BinaryOp, UnaryOp>(binaryOp, unaryOp); -}; - -template<typename Pair> -class Ascend1st:public std::binary_function<Pair, Pair, bool> -{ -public: - bool operator()(const Pair& p1, const Pair& p2) const - { - return p1.first < p2.first; - } -}; - -template<typename Pair> -class select2nd -{ -public: - typename Pair::second_type operator()(const Pair& p) const - { - return p.second; - } - - typename Pair::second_type operator()(Pair& p) const - { - return p.second; - } -}; - class Deleter { public: template<class T> |
