Non-public construction, but moveable:
| 33 | }; |
| 34 | // Non-public construction, but moveable: |
| 35 | class 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 | |
| 41 | public: |
| 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: |
| 54 | class TestFactory3 { |
| 55 | protected: |