mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-22 09:06:18 +00:00
* Starting work on resource manager.
* Modified rak::accumulate to require accessing ::result instead of using a reference. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@568 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+23
-4
@@ -51,20 +51,35 @@ struct reference_fix<Type&> {
|
||||
typedef Type type;
|
||||
};
|
||||
|
||||
template <typename Type>
|
||||
struct value_t {
|
||||
value_t(Type v) : m_v(v) {}
|
||||
|
||||
Type operator () () const { return m_v; }
|
||||
|
||||
Type m_v;
|
||||
};
|
||||
|
||||
template <typename Type>
|
||||
inline value_t<Type>
|
||||
value(Type v) {
|
||||
return value_t<Type>(v);
|
||||
}
|
||||
|
||||
template <typename Type, typename Ftor>
|
||||
struct accumulate_t {
|
||||
accumulate_t(Type& t, Ftor f) : m_t(t), m_f(f) {}
|
||||
accumulate_t(Type t, Ftor f) : result(t), m_f(f) {}
|
||||
|
||||
template <typename Arg>
|
||||
void operator () (Arg& a) { m_t += m_f(a); }
|
||||
void operator () (const Arg& a) { result += m_f(a); }
|
||||
|
||||
Type& m_t;
|
||||
Type result;
|
||||
Ftor m_f;
|
||||
};
|
||||
|
||||
template <typename Type, typename Ftor>
|
||||
inline accumulate_t<Type, Ftor>
|
||||
accumulate(Type& t, Ftor f) {
|
||||
accumulate(Type t, Ftor f) {
|
||||
return accumulate_t<Type, Ftor>(t, f);
|
||||
}
|
||||
|
||||
@@ -225,6 +240,10 @@ struct mem_ptr_ref_t : public std::unary_function<Class&, Member&> {
|
||||
return c.*m_member;
|
||||
}
|
||||
|
||||
const Member& operator () (const Class& c) {
|
||||
return c.*m_member;
|
||||
}
|
||||
|
||||
Member Class::*m_member;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user