Eric Fiselier | 1c0cedc | 2017-10-17 13:03:17 +0000 | [diff] [blame] | 1 | #ifndef TEST_SUPPORT_EMPLACE_CONSTRUCTIBLE_H |
| 2 | #define TEST_SUPPORT_EMPLACE_CONSTRUCTIBLE_H |
| 3 | |
| 4 | #include "test_macros.h" |
| 5 | |
| 6 | #if TEST_STD_VER >= 11 |
| 7 | template <class T> |
| 8 | struct EmplaceConstructible { |
| 9 | T value; |
Eric Fiselier | 8092cbf | 2017-10-17 13:45:20 +0000 | [diff] [blame] | 10 | explicit EmplaceConstructible(T xvalue) : value(xvalue) {} |
Eric Fiselier | 1c0cedc | 2017-10-17 13:03:17 +0000 | [diff] [blame] | 11 | EmplaceConstructible(EmplaceConstructible const&) = delete; |
| 12 | }; |
| 13 | |
| 14 | template <class T> |
| 15 | struct EmplaceConstructibleAndMoveInsertable { |
| 16 | int copied = 0; |
| 17 | T value; |
Eric Fiselier | 8092cbf | 2017-10-17 13:45:20 +0000 | [diff] [blame] | 18 | explicit EmplaceConstructibleAndMoveInsertable(T xvalue) : value(xvalue) {} |
Eric Fiselier | 1c0cedc | 2017-10-17 13:03:17 +0000 | [diff] [blame] | 19 | |
| 20 | EmplaceConstructibleAndMoveInsertable( |
| 21 | EmplaceConstructibleAndMoveInsertable&& Other) |
| 22 | : copied(Other.copied + 1), value(std::move(Other.value)) {} |
| 23 | }; |
| 24 | |
| 25 | template <class T> |
| 26 | struct EmplaceConstructibleAndMoveable { |
| 27 | int copied = 0; |
| 28 | int assigned = 0; |
| 29 | T value; |
Eric Fiselier | 8092cbf | 2017-10-17 13:45:20 +0000 | [diff] [blame] | 30 | explicit EmplaceConstructibleAndMoveable(T xvalue) noexcept : value(xvalue) {} |
Eric Fiselier | 1c0cedc | 2017-10-17 13:03:17 +0000 | [diff] [blame] | 31 | |
| 32 | EmplaceConstructibleAndMoveable(EmplaceConstructibleAndMoveable&& Other) |
| 33 | noexcept : copied(Other.copied + 1), |
| 34 | value(std::move(Other.value)) {} |
| 35 | |
| 36 | EmplaceConstructibleAndMoveable& |
| 37 | operator=(EmplaceConstructibleAndMoveable&& Other) noexcept { |
| 38 | copied = Other.copied; |
| 39 | assigned = Other.assigned + 1; |
| 40 | value = std::move(Other.value); |
| 41 | return *this; |
| 42 | } |
| 43 | }; |
| 44 | |
| 45 | template <class T> |
| 46 | struct EmplaceConstructibleMoveableAndAssignable { |
| 47 | int copied = 0; |
| 48 | int assigned = 0; |
| 49 | T value; |
Eric Fiselier | ffcc7c6 | 2017-10-17 16:06:42 +0000 | [diff] [blame] | 50 | explicit EmplaceConstructibleMoveableAndAssignable(T xvalue) noexcept |
| 51 | : value(xvalue) {} |
Eric Fiselier | 1c0cedc | 2017-10-17 13:03:17 +0000 | [diff] [blame] | 52 | |
| 53 | EmplaceConstructibleMoveableAndAssignable( |
| 54 | EmplaceConstructibleMoveableAndAssignable&& Other) noexcept |
| 55 | : copied(Other.copied + 1), |
| 56 | value(std::move(Other.value)) {} |
| 57 | |
| 58 | EmplaceConstructibleMoveableAndAssignable& |
| 59 | operator=(EmplaceConstructibleMoveableAndAssignable&& Other) noexcept { |
| 60 | copied = Other.copied; |
| 61 | assigned = Other.assigned + 1; |
| 62 | value = std::move(Other.value); |
| 63 | return *this; |
| 64 | } |
| 65 | |
| 66 | EmplaceConstructibleMoveableAndAssignable& operator=(T xvalue) { |
| 67 | value = std::move(xvalue); |
| 68 | ++assigned; |
| 69 | return *this; |
| 70 | } |
| 71 | }; |
| 72 | #endif |
| 73 | |
| 74 | #endif // TEST_SUPPORT_EMPLACE_CONSTRUCTIBLE_H |