MCPcopy Create free account
hub / github.com/pybind/pybind11 / NonCopyable

Class NonCopyable

tests/test_virtual_functions.cpp:100–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98};
99
100class NonCopyable {
101public:
102 NonCopyable(int a, int b) : value{new int(a * b)} { print_created(this, a, b); }
103 NonCopyable(NonCopyable &&o) noexcept : value{std::move(o.value)} { print_move_created(this); }
104 NonCopyable(const NonCopyable &) = delete;
105 NonCopyable() = delete;
106 void operator=(const NonCopyable &) = delete;
107 void operator=(NonCopyable &&) = delete;
108 std::string get_value() const {
109 if (value) {
110 return std::to_string(*value);
111 }
112 return "(null)";
113 }
114 ~NonCopyable() { print_destroyed(this); }
115
116private:
117 std::unique_ptr<int> value;
118};
119
120// This is like the above, but is both copy and movable. In effect this means it should get moved
121// when it is not referenced elsewhere, but copied if it is still referenced.

Callers 1

get_noncopyableFunction · 0.85

Calls

no outgoing calls

Tested by 1

get_noncopyableFunction · 0.68