mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-17 22:03:07 -06:00
Core: WithPick
git-svn-id: svn://ultimatepp.org/upp/trunk@7279 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
ff217d5a92
commit
768bbb9c3b
1 changed files with 22 additions and 6 deletions
|
|
@ -267,12 +267,13 @@ public:
|
|||
template <class T>
|
||||
class WithDeepCopy : public T {
|
||||
public:
|
||||
WithDeepCopy(const T& a) : T(a, 1) {}
|
||||
WithDeepCopy(const WithDeepCopy& a) : T(a, 1) {}
|
||||
WithDeepCopy& operator=(const WithDeepCopy& a) { (T&)*this <<= a; return *this; }
|
||||
WithDeepCopy(int, T rval_ a) : T(a) {}
|
||||
WithDeepCopy& operator^=(T rval_ a) { (T&)*this = pick(a); return *this; }
|
||||
WithDeepCopy() {}
|
||||
WithDeepCopy(const T& a) : T(clone(a)) {}
|
||||
WithDeepCopy(const WithDeepCopy& a) : T(clone(a)){}
|
||||
WithDeepCopy& operator=(const WithDeepCopy& a) { (T&)*this = clone(a); return *this; }
|
||||
WithDeepCopy& operator=(const T& a) { (T&)*this = clone(a); return *this; }
|
||||
// WithDeepCopy(int, T rval_ a) : T(a) {}
|
||||
// WithDeepCopy& operator^=(T rval_ a) { (T&)*this = pick(a); return *this; }
|
||||
WithDeepCopy() {}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
|
@ -281,6 +282,21 @@ WithDeepCopy<T> DeepClone(const T& src)
|
|||
return WithDeepCopy<T>(src);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
class WithPick : public T {
|
||||
public:
|
||||
WithPick(const T& a) : T(pick(a)) {}
|
||||
WithPick(const WithPick& a) : T(pick(a)) {}
|
||||
WithPick& operator=(const WithPick& a) { (T&)*this = pick(a); return *this; }
|
||||
WithPick& operator=(const T& a) { (T&)*this = pick(a); return *this; }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
WithPick<T> AsPick(T rval src)
|
||||
{
|
||||
return WithPick<T>(src);
|
||||
}
|
||||
|
||||
// STL compatibility hacks
|
||||
|
||||
#define STL_ITERATOR_COMPATIBILITY \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue