diff --git a/uppsrc/Core/Topt.h b/uppsrc/Core/Topt.h index 7c3b0cd43..1e8a2617c 100644 --- a/uppsrc/Core/Topt.h +++ b/uppsrc/Core/Topt.h @@ -267,12 +267,13 @@ public: template 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 @@ -281,6 +282,21 @@ WithDeepCopy DeepClone(const T& src) return WithDeepCopy(src); } +template +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 +WithPick AsPick(T rval src) +{ + return WithPick(src); +} + // STL compatibility hacks #define STL_ITERATOR_COMPATIBILITY \