blob: 4490de10c3ae5201d68eab07d2b8cd82d86eff28 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#pragma once
#include <util/generic/utility.h>
template <typename T>
class TMoved {
private:
mutable T Value;
public:
TMoved() {
}
TMoved(const TMoved<T>& that) {
DoSwap(Value, that.Value);
}
TMoved(const T& that) {
DoSwap(Value, const_cast<T&>(that));
}
void swap(TMoved& that) {
DoSwap(Value, that.Value);
}
T& operator*() {
return Value;
}
const T& operator*() const {
return Value;
}
T* operator->() {
return &Value;
}
const T* operator->() const {
return &Value;
}
};
|