We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2253b3c commit 0264b41Copy full SHA for 0264b41
include/move_on_copy.hh
@@ -0,0 +1,22 @@
1
+template <typename T>
2
+class move_on_copy {
3
+public:
4
+ move_on_copy(T&& aValue)
5
+ : value_(std::move(aValue)) {}
6
+ move_on_copy(const move_on_copy& other)
7
+ : value_(std::move(other.value_)) {}
8
+
9
+ move_on_copy& operator=(move_on_copy&& aValue) = delete;
10
+ move_on_copy& operator=(const move_on_copy& aValue) = delete;
11
12
+ T& value() { return value_; }
13
+ const T& value() const { return value_; }
14
15
+private:
16
+ mutable T value_;
17
+};
18
19
20
+inline move_on_copy<T> make_move_on_copy(T&& aValue) {
21
+ return move_on_copy<T>(std::move(aValue));
22
+}
0 commit comments