|
| 1 | +#include <simply/copyable.hpp> |
| 2 | +#include <simply/destructible.hpp> |
| 3 | +#include <simply/dyn.hpp> |
| 4 | +#include <simply/movable.hpp> |
| 5 | + |
| 6 | +struct semiregular { |
| 7 | + semiregular(); |
| 8 | + semiregular(const semiregular &); |
| 9 | + semiregular(semiregular &&) noexcept; |
| 10 | + |
| 11 | + auto operator=(const semiregular &) -> semiregular &; |
| 12 | + auto operator=(semiregular &&) noexcept -> semiregular &; |
| 13 | + |
| 14 | + ~semiregular(); |
| 15 | +}; |
| 16 | + |
| 17 | +struct uncopyable { |
| 18 | + uncopyable(); |
| 19 | + uncopyable(const uncopyable &) = delete; |
| 20 | + uncopyable(uncopyable &&) noexcept; |
| 21 | + |
| 22 | + auto operator=(const uncopyable &) -> uncopyable &; |
| 23 | + auto operator=(uncopyable &&) noexcept -> uncopyable &; |
| 24 | + |
| 25 | + ~uncopyable(); |
| 26 | +}; |
| 27 | + |
| 28 | +struct immovable { |
| 29 | + immovable(); |
| 30 | + immovable(const immovable &); |
| 31 | + immovable(immovable &&) = delete; |
| 32 | + |
| 33 | + auto operator=(const immovable &) -> immovable &; |
| 34 | + auto operator=(immovable &&) noexcept -> immovable &; |
| 35 | + |
| 36 | + ~immovable(); |
| 37 | +}; |
| 38 | + |
| 39 | +struct indestructible { |
| 40 | + indestructible(); |
| 41 | + indestructible(const indestructible &); |
| 42 | + indestructible(indestructible &&) noexcept; |
| 43 | + |
| 44 | + auto operator=(const indestructible &) -> indestructible &; |
| 45 | + auto operator=(indestructible &&) noexcept -> indestructible &; |
| 46 | + |
| 47 | + ~indestructible() = delete; |
| 48 | +}; |
| 49 | + |
| 50 | +using unusable = simply::dyn<simply::composes<>>; |
| 51 | +using copyable = simply::dyn<simply::copyable>; |
| 52 | +using movable = simply::dyn<simply::movable>; |
| 53 | +using destructible = simply::dyn<simply::destructible>; |
| 54 | + |
| 55 | +template <typename T, typename U> |
| 56 | +concept constructible_from_in_place = |
| 57 | + simply::constructible_from<T, std::in_place_type_t<U>>; |
| 58 | + |
| 59 | +static_assert(constructible_from_in_place<unusable, semiregular>); |
| 60 | +static_assert(constructible_from_in_place<unusable, uncopyable>); |
| 61 | +static_assert(constructible_from_in_place<unusable, immovable>); |
| 62 | +static_assert(constructible_from_in_place<unusable, indestructible>); |
| 63 | + |
| 64 | +static_assert(not simply::copy_constructible<unusable>); |
| 65 | +static_assert(not simply::move_constructible<unusable>); |
| 66 | +static_assert(not std::is_destructible_v<unusable>); |
| 67 | + |
| 68 | +static_assert(constructible_from_in_place<copyable, semiregular>); |
| 69 | +static_assert(not constructible_from_in_place<copyable, uncopyable>); |
| 70 | +static_assert(constructible_from_in_place<copyable, immovable>); |
| 71 | +// TODO reimplement copyable not to depend on destruction |
| 72 | +// clang is the only compiler that thinks it doesn't |
| 73 | +#if defined(__clang__) |
| 74 | +static_assert(constructible_from_in_place<copyable, indestructible>); |
| 75 | +#endif |
| 76 | + |
| 77 | +static_assert(simply::copy_constructible<copyable>); |
| 78 | +static_assert(not simply::move_constructible<copyable>); |
| 79 | +static_assert(not std::is_destructible_v<copyable>); |
| 80 | + |
| 81 | +static_assert(constructible_from_in_place<movable, semiregular>); |
| 82 | +static_assert(constructible_from_in_place<movable, uncopyable>); |
| 83 | +static_assert(not constructible_from_in_place<movable, immovable>); |
| 84 | +// TODO reimplement movable not to depend on destruction |
| 85 | +// clang is the only compiler that thinks it doesn't |
| 86 | +#if defined(__clang__) |
| 87 | +static_assert(constructible_from_in_place<movable, indestructible>); |
| 88 | +#endif |
| 89 | + |
| 90 | +static_assert(not simply::copy_constructible<movable>); |
| 91 | +static_assert(simply::move_constructible<movable>); |
| 92 | +static_assert(not std::is_destructible_v<movable>); |
| 93 | + |
| 94 | +static_assert(constructible_from_in_place<destructible, semiregular>); |
| 95 | +static_assert(constructible_from_in_place<destructible, uncopyable>); |
| 96 | +static_assert(constructible_from_in_place<destructible, immovable>); |
| 97 | +static_assert(not constructible_from_in_place<destructible, indestructible>); |
| 98 | + |
| 99 | +static_assert(not simply::copy_constructible<destructible>); |
| 100 | +static_assert(not simply::move_constructible<destructible>); |
| 101 | +static_assert(std::is_destructible_v<destructible>); |
0 commit comments