diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:18:58 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:18:58 +0000 |
| commit | 53a420fba21cf1644972b34dcd811a43cdb8368d (patch) | |
| tree | 66a19f6f8b65215772549a51d688492ab8addc0d /test/libcxx/utilities/optional/optional.object/optional.object.ctor | |
| parent | b50f1549701eb950921e5d6f2e55ba1a1dadbb43 (diff) | |
Notes
Diffstat (limited to 'test/libcxx/utilities/optional/optional.object/optional.object.ctor')
| -rw-r--r-- | test/libcxx/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp | 59 | ||||
| -rw-r--r-- | test/libcxx/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp | 60 |
2 files changed, 119 insertions, 0 deletions
diff --git a/test/libcxx/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp b/test/libcxx/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp new file mode 100644 index 000000000000..62eb6cd34880 --- /dev/null +++ b/test/libcxx/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// <optional> + +// optional(const optional<T>& rhs); + +#include <optional> +#include <string> +#include <type_traits> + +using std::optional; + +struct X {}; + +struct Y +{ + Y() = default; + Y(const Y&) {} +}; + +struct Z +{ + Z() = default; + Z(Z&&) = delete; + Z(const Z&) = delete; + Z& operator=(Z&&) = delete; + Z& operator=(const Z&) = delete; +}; + +int main() +{ + { + using T = int; + static_assert((std::is_trivially_copy_constructible<optional<T>>::value), ""); + constexpr optional<T> opt; + constexpr optional<T> opt2 = opt; + (void)opt2; + } + { + using T = X; + static_assert((std::is_trivially_copy_constructible<optional<T>>::value), ""); + constexpr optional<T> opt; + constexpr optional<T> opt2 = opt; + (void)opt2; + } + static_assert(!(std::is_trivially_copy_constructible<optional<Y>>::value), ""); + static_assert(!(std::is_trivially_copy_constructible<optional<std::string>>::value), ""); + + static_assert(!(std::is_copy_constructible<optional<Z>>::value), ""); +} diff --git a/test/libcxx/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp b/test/libcxx/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp new file mode 100644 index 000000000000..f13ca92e2807 --- /dev/null +++ b/test/libcxx/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// <optional> + +// optional(optional<T>&& rhs); + +#include <optional> +#include <string> +#include <type_traits> +#include <utility> + +using std::optional; + +struct X {}; + +struct Y +{ + Y() = default; + Y(Y&&) {} +}; + +struct Z +{ + Z() = default; + Z(Z&&) = delete; + Z(const Z&) = delete; + Z& operator=(Z&&) = delete; + Z& operator=(const Z&) = delete; +}; + +int main() +{ + { + using T = int; + static_assert((std::is_trivially_copy_constructible<optional<T>>::value), ""); + constexpr optional<T> opt; + constexpr optional<T> opt2 = std::move(opt); + (void)opt2; + } + { + using T = X; + static_assert((std::is_trivially_copy_constructible<optional<T>>::value), ""); + constexpr optional<T> opt; + constexpr optional<T> opt2 = std::move(opt); + (void)opt2; + } + static_assert(!(std::is_trivially_move_constructible<optional<Y>>::value), ""); + static_assert(!(std::is_trivially_move_constructible<optional<std::string>>::value), ""); + + static_assert(!(std::is_move_constructible<optional<Z>>::value), ""); +} |
