diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-02 12:47:11 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-02 12:47:11 +0000 |
commit | dbabdb5220c44e5938d404eefb84b5ed55667ea8 (patch) | |
tree | 75c7e5204ae0564ac641b1629ef74066461d1884 /test/support/emplace_constructible.h | |
parent | 8a86acebf859efb1adc46c88fa0cd69381a7291f (diff) |
Notes
Diffstat (limited to 'test/support/emplace_constructible.h')
-rw-r--r-- | test/support/emplace_constructible.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/test/support/emplace_constructible.h b/test/support/emplace_constructible.h new file mode 100644 index 000000000000..f2bc0ec6a367 --- /dev/null +++ b/test/support/emplace_constructible.h @@ -0,0 +1,74 @@ +#ifndef TEST_SUPPORT_EMPLACE_CONSTRUCTIBLE_H +#define TEST_SUPPORT_EMPLACE_CONSTRUCTIBLE_H + +#include "test_macros.h" + +#if TEST_STD_VER >= 11 +template <class T> +struct EmplaceConstructible { + T value; + explicit EmplaceConstructible(T value) : value(value) {} + EmplaceConstructible(EmplaceConstructible const&) = delete; +}; + +template <class T> +struct EmplaceConstructibleAndMoveInsertable { + int copied = 0; + T value; + explicit EmplaceConstructibleAndMoveInsertable(T value) : value(value) {} + + EmplaceConstructibleAndMoveInsertable( + EmplaceConstructibleAndMoveInsertable&& Other) + : copied(Other.copied + 1), value(std::move(Other.value)) {} +}; + +template <class T> +struct EmplaceConstructibleAndMoveable { + int copied = 0; + int assigned = 0; + T value; + explicit EmplaceConstructibleAndMoveable(T value) noexcept : value(value) {} + + EmplaceConstructibleAndMoveable(EmplaceConstructibleAndMoveable&& Other) + noexcept : copied(Other.copied + 1), + value(std::move(Other.value)) {} + + EmplaceConstructibleAndMoveable& + operator=(EmplaceConstructibleAndMoveable&& Other) noexcept { + copied = Other.copied; + assigned = Other.assigned + 1; + value = std::move(Other.value); + return *this; + } +}; + +template <class T> +struct EmplaceConstructibleMoveableAndAssignable { + int copied = 0; + int assigned = 0; + T value; + explicit EmplaceConstructibleMoveableAndAssignable(T value) noexcept + : value(value) {} + + EmplaceConstructibleMoveableAndAssignable( + EmplaceConstructibleMoveableAndAssignable&& Other) noexcept + : copied(Other.copied + 1), + value(std::move(Other.value)) {} + + EmplaceConstructibleMoveableAndAssignable& + operator=(EmplaceConstructibleMoveableAndAssignable&& Other) noexcept { + copied = Other.copied; + assigned = Other.assigned + 1; + value = std::move(Other.value); + return *this; + } + + EmplaceConstructibleMoveableAndAssignable& operator=(T xvalue) { + value = std::move(xvalue); + ++assigned; + return *this; + } +}; +#endif + +#endif // TEST_SUPPORT_EMPLACE_CONSTRUCTIBLE_H |