mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 06:39:23 +00:00
Fixed compile issues with C++03.
This commit is contained in:
+12
-10
@@ -53,6 +53,8 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <tr1/functional>
|
||||||
|
#include <tr1/memory>
|
||||||
|
|
||||||
namespace rak {
|
namespace rak {
|
||||||
|
|
||||||
@@ -96,13 +98,13 @@ public:
|
|||||||
|
|
||||||
bool is_valid() const { return m_base.get() != NULL; }
|
bool is_valid() const { return m_base.get() != NULL; }
|
||||||
|
|
||||||
void set(base_type* base) { m_base = std::shared_ptr<base_type>(base); }
|
void set(base_type* base) { m_base = std::tr1::shared_ptr<base_type>(base); }
|
||||||
base_type* release() { return m_base.release(); }
|
base_type* release() { return m_base.release(); }
|
||||||
|
|
||||||
Result operator () () { return (*m_base)(); }
|
Result operator () () { return (*m_base)(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<base_type> m_base;
|
std::tr1::shared_ptr<base_type> m_base;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Result, typename Arg1>
|
template <typename Result, typename Arg1>
|
||||||
@@ -113,13 +115,13 @@ public:
|
|||||||
|
|
||||||
bool is_valid() const { return m_base.get() != NULL; }
|
bool is_valid() const { return m_base.get() != NULL; }
|
||||||
|
|
||||||
void set(base_type* base) { m_base = std::shared_ptr<base_type>(base); }
|
void set(base_type* base) { m_base = std::tr1::shared_ptr<base_type>(base); }
|
||||||
base_type* release() { return m_base.release(); }
|
base_type* release() { return m_base.release(); }
|
||||||
|
|
||||||
Result operator () (Arg1 arg1) { return (*m_base)(arg1); }
|
Result operator () (Arg1 arg1) { return (*m_base)(arg1); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<base_type> m_base;
|
std::tr1::shared_ptr<base_type> m_base;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Result, typename Arg1, typename Arg2>
|
template <typename Result, typename Arg1, typename Arg2>
|
||||||
@@ -130,13 +132,13 @@ public:
|
|||||||
|
|
||||||
bool is_valid() const { return m_base.get() != NULL; }
|
bool is_valid() const { return m_base.get() != NULL; }
|
||||||
|
|
||||||
void set(base_type* base) { m_base = std::shared_ptr<base_type>(base); }
|
void set(base_type* base) { m_base = std::tr1::shared_ptr<base_type>(base); }
|
||||||
base_type* release() { return m_base.release(); }
|
base_type* release() { return m_base.release(); }
|
||||||
|
|
||||||
Result operator () (Arg1 arg1, Arg2 arg2) { return (*m_base)(arg1, arg2); }
|
Result operator () (Arg1 arg1, Arg2 arg2) { return (*m_base)(arg1, arg2); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<base_type> m_base;
|
std::tr1::shared_ptr<base_type> m_base;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Result, typename Arg2>
|
template <typename Result, typename Arg2>
|
||||||
@@ -147,7 +149,7 @@ public:
|
|||||||
|
|
||||||
bool is_valid() const { return m_base.get() != NULL; }
|
bool is_valid() const { return m_base.get() != NULL; }
|
||||||
|
|
||||||
void set(base_type* base) { m_base = std::shared_ptr<base_type>(base); }
|
void set(base_type* base) { m_base = std::tr1::shared_ptr<base_type>(base); }
|
||||||
base_type* release() { return m_base.release(); }
|
base_type* release() { return m_base.release(); }
|
||||||
|
|
||||||
Result operator () (Arg2 arg2) { return (*m_base)(arg2); }
|
Result operator () (Arg2 arg2) { return (*m_base)(arg2); }
|
||||||
@@ -156,7 +158,7 @@ public:
|
|||||||
Result operator () (Discard discard, Arg2 arg2) { return (*m_base)(arg2); }
|
Result operator () (Discard discard, Arg2 arg2) { return (*m_base)(arg2); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<base_type> m_base;
|
std::tr1::shared_ptr<base_type> m_base;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Result, typename Arg1, typename Arg2, typename Arg3>
|
template <typename Result, typename Arg1, typename Arg2, typename Arg3>
|
||||||
@@ -167,13 +169,13 @@ public:
|
|||||||
|
|
||||||
bool is_valid() const { return m_base.get() != NULL; }
|
bool is_valid() const { return m_base.get() != NULL; }
|
||||||
|
|
||||||
void set(base_type* base) { m_base = std::shared_ptr<base_type>(base); }
|
void set(base_type* base) { m_base = std::tr1::shared_ptr<base_type>(base); }
|
||||||
base_type* release() { return m_base.release(); }
|
base_type* release() { return m_base.release(); }
|
||||||
|
|
||||||
Result operator () (Arg1 arg1, Arg2 arg2, Arg3 arg3) { return (*m_base)(arg1, arg2, arg3); }
|
Result operator () (Arg1 arg1, Arg2 arg2, Arg3 arg3) { return (*m_base)(arg1, arg2, arg3); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<base_type> m_base;
|
std::tr1::shared_ptr<base_type> m_base;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Result>
|
template <typename Result>
|
||||||
|
|||||||
@@ -41,6 +41,10 @@
|
|||||||
#include "rpc/parse_commands.h"
|
#include "rpc/parse_commands.h"
|
||||||
#include "rpc/object_storage.h"
|
#include "rpc/object_storage.h"
|
||||||
|
|
||||||
|
#ifndef HAVE_CXX11
|
||||||
|
namespace std { using namespace tr1; }
|
||||||
|
#endif
|
||||||
|
|
||||||
void initialize_commands();
|
void initialize_commands();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
+2
-2
@@ -111,7 +111,7 @@ typedef rt_triple<int, void*, void*> target_type;
|
|||||||
class command_base;
|
class command_base;
|
||||||
|
|
||||||
typedef const torrent::Object (*command_base_call_type)(command_base*, target_type, const torrent::Object&);
|
typedef const torrent::Object (*command_base_call_type)(command_base*, target_type, const torrent::Object&);
|
||||||
typedef std::function<torrent::Object (target_type, const torrent::Object&)> base_function;
|
typedef tr1::function<torrent::Object (target_type, const torrent::Object&)> base_function;
|
||||||
|
|
||||||
template <typename tmpl> struct command_base_is_valid {};
|
template <typename tmpl> struct command_base_is_valid {};
|
||||||
template <command_base_call_type tmpl_func> struct command_base_is_type {};
|
template <command_base_call_type tmpl_func> struct command_base_is_type {};
|
||||||
@@ -250,7 +250,7 @@ command_base::_call(command_base* cmd, target_type target, Args args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define COMMAND_BASE_TEMPLATE_TYPE(func_type, func_parm) \
|
#define COMMAND_BASE_TEMPLATE_TYPE(func_type, func_parm) \
|
||||||
template <typename T, int proper = target_type_id<T>::proper_type> struct func_type { typedef std::function<func_parm> type; }; \
|
template <typename T, int proper = target_type_id<T>::proper_type> struct func_type { typedef tr1::function<func_parm> type; }; \
|
||||||
\
|
\
|
||||||
template <> struct command_base_is_valid<func_type<target_type>::type> { static const int value = 1; }; \
|
template <> struct command_base_is_valid<func_type<target_type>::type> { static const int value = 1; }; \
|
||||||
template <> struct command_base_is_valid<func_type<core::Download*>::type> { static const int value = 1; }; \
|
template <> struct command_base_is_valid<func_type<core::Download*>::type> { static const int value = 1; }; \
|
||||||
|
|||||||
Reference in New Issue
Block a user