|
@@ -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>
|