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

Class TestFactory2

tests/test_factory_constructors.cpp:35–52  ·  view source on GitHub ↗

Non-public construction, but moveable:

Source from the content-addressed store, hash-verified

33};
34// Non-public construction, but moveable:
35class TestFactory2 {
36 friend class TestFactoryHelper;
37 TestFactory2() : value("(empty2)") { print_default_created(this); }
38 explicit TestFactory2(int v) : value(std::to_string(v)) { print_created(this, value); }
39 explicit TestFactory2(std::string v) : value(std::move(v)) { print_created(this, value); }
40
41public:
42 TestFactory2(TestFactory2 &&m) noexcept : value{std::move(m.value)} {
43 print_move_created(this);
44 }
45 TestFactory2 &operator=(TestFactory2 &&m) noexcept {
46 value = std::move(m.value);
47 print_move_assigned(this);
48 return *this;
49 }
50 std::string value;
51 ~TestFactory2() { print_destroyed(this); }
52};
53// Mixed direct/factory construction:
54class TestFactory3 {
55protected:

Callers 1

construct2Method · 0.85

Calls 2

moveFunction · 0.85
print_move_assignedFunction · 0.85

Tested by 1

construct2Method · 0.68