diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-10-12 06:48:31 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-10-12 06:48:31 +0000 |
commit | fc647db3ee8215ab2fa5f7cdea8d327c2faa768f (patch) | |
tree | e81dc360c9c06b9a32303243d77c4c7325f8897f /libcxx/test/std/utilities/optional/optional.object/optional.object.observe | |
parent | 6ee4001cc957acac39181b68193e1414c3163698 (diff) | |
download | bcm5719-llvm-fc647db3ee8215ab2fa5f7cdea8d327c2faa768f.tar.gz bcm5719-llvm-fc647db3ee8215ab2fa5f7cdea8d327c2faa768f.zip |
Revert Add <optional>. Will recommit with better commit message
llvm-svn: 283978
Diffstat (limited to 'libcxx/test/std/utilities/optional/optional.object/optional.object.observe')
15 files changed, 0 insertions, 957 deletions
diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/bool.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/bool.pass.cpp deleted file mode 100644 index 9820d50f632..00000000000 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/bool.pass.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// constexpr explicit optional<T>::operator bool() const noexcept; - -#include <optional> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -int main() -{ - using std::optional; - { - const optional<int> opt; ((void)opt); - ASSERT_NOEXCEPT(bool(opt)); - static_assert(!std::is_convertible<optional<int>, bool>::value, ""); - } - { - constexpr optional<int> opt; - static_assert(!opt, ""); - } - { - constexpr optional<int> opt(0); - static_assert(opt, ""); - } -} diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp deleted file mode 100644 index 4087cfdf104..00000000000 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp +++ /dev/null @@ -1,73 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// constexpr T& optional<T>::operator*() &; - -#ifdef _LIBCPP_DEBUG -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - -#include <optional> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -using std::optional; - -struct X -{ - constexpr int test() const& {return 3;} - int test() & {return 4;} - constexpr int test() const&& {return 5;} - int test() && {return 6;} -}; - -struct Y -{ - constexpr int test() {return 7;} -}; - -constexpr int -test() -{ - optional<Y> opt{Y{}}; - return (*opt).test(); -} - -int main() -{ - { - optional<X> opt; ((void)opt); - ASSERT_SAME_TYPE(decltype(*opt), X&); - // ASSERT_NOT_NOEXCEPT(*opt); - // FIXME: This assertion fails with GCC because it can see that - // (A) operator*() is constexpr, and - // (B) there is no path through the function that throws. - // It's arguable if this is the correct behavior for the noexcept - // operator. - // Regardless this function should still be noexcept(false) because - // it has a narrow contract. - } - { - optional<X> opt(X{}); - assert((*opt).test() == 4); - } - static_assert(test() == 7, ""); -#ifdef _LIBCPP_DEBUG - { - optional<X> opt; - assert((*opt).test() == 3); - assert(false); - } -#endif // _LIBCPP_DEBUG -} diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp deleted file mode 100644 index 0779c9047c9..00000000000 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp +++ /dev/null @@ -1,69 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// constexpr const T& optional<T>::operator*() const &; - -#ifdef _LIBCPP_DEBUG -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - -#include <optional> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -using std::optional; - -struct X -{ - constexpr int test() const& {return 3;} - int test() & {return 4;} - constexpr int test() const&& {return 5;} - int test() && {return 6;} -}; - -struct Y -{ - int test() const {return 2;} -}; - -int main() -{ - { - const optional<X> opt; ((void)opt); - ASSERT_SAME_TYPE(decltype(*opt), X const&); - // ASSERT_NOT_NOEXCEPT(*opt); - // FIXME: This assertion fails with GCC because it can see that - // (A) operator*() is constexpr, and - // (B) there is no path through the function that throws. - // It's arguable if this is the correct behavior for the noexcept - // operator. - // Regardless this function should still be noexcept(false) because - // it has a narrow contract. - } - { - constexpr optional<X> opt(X{}); - static_assert((*opt).test() == 3, ""); - } - { - constexpr optional<Y> opt(Y{}); - assert((*opt).test() == 2); - } -#ifdef _LIBCPP_DEBUG - { - const optional<X> opt; - assert((*opt).test() == 3); - assert(false); - } -#endif // _LIBCPP_DEBUG -} diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const_rvalue.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const_rvalue.pass.cpp deleted file mode 100644 index 78fd992952c..00000000000 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const_rvalue.pass.cpp +++ /dev/null @@ -1,69 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// constexpr T&& optional<T>::operator*() const &&; - -#ifdef _LIBCPP_DEBUG -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - -#include <optional> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -using std::optional; - -struct X -{ - constexpr int test() const& {return 3;} - int test() & {return 4;} - constexpr int test() const&& {return 5;} - int test() && {return 6;} -}; - -struct Y -{ - int test() const && {return 2;} -}; - -int main() -{ - { - const optional<X> opt; ((void)opt); - ASSERT_SAME_TYPE(decltype(*std::move(opt)), X const &&); - // ASSERT_NOT_NOEXCEPT(*std::move(opt)); - // FIXME: This assertion fails with GCC because it can see that - // (A) operator*() is constexpr, and - // (B) there is no path through the function that throws. - // It's arguable if this is the correct behavior for the noexcept - // operator. - // Regardless this function should still be noexcept(false) because - // it has a narrow contract. - } - { - constexpr optional<X> opt(X{}); - static_assert((*std::move(opt)).test() == 5, ""); - } - { - constexpr optional<Y> opt(Y{}); - assert((*std::move(opt)).test() == 2); - } -#ifdef _LIBCPP_DEBUG - { - optional<X> opt; - assert((*std::move(opt)).test() == 5); - assert(false); - } -#endif // _LIBCPP_DEBUG -} diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_rvalue.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_rvalue.pass.cpp deleted file mode 100644 index 2924123234a..00000000000 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_rvalue.pass.cpp +++ /dev/null @@ -1,73 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// constexpr T&& optional<T>::operator*() &&; - -#ifdef _LIBCPP_DEBUG -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - -#include <optional> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -using std::optional; - -struct X -{ - constexpr int test() const& {return 3;} - int test() & {return 4;} - constexpr int test() const&& {return 5;} - int test() && {return 6;} -}; - -struct Y -{ - constexpr int test() && {return 7;} -}; - -constexpr int -test() -{ - optional<Y> opt{Y{}}; - return (*std::move(opt)).test(); -} - -int main() -{ - { - optional<X> opt; ((void)opt); - ASSERT_SAME_TYPE(decltype(*std::move(opt)), X&&); - // ASSERT_NOT_NOEXCEPT(*std::move(opt)); - // FIXME: This assertion fails with GCC because it can see that - // (A) operator*() is constexpr, and - // (B) there is no path through the function that throws. - // It's arguable if this is the correct behavior for the noexcept - // operator. - // Regardless this function should still be noexcept(false) because - // it has a narrow contract. - } - { - optional<X> opt(X{}); - assert((*std::move(opt)).test() == 6); - } - static_assert(test() == 7, ""); -#ifdef _LIBCPP_DEBUG - { - optional<X> opt; - assert((*std::move(opt)).test() == 3); - assert(false); - } -#endif // _LIBCPP_DEBUG -} diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/has_value.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/has_value.pass.cpp deleted file mode 100644 index 5df295d01e2..00000000000 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/has_value.pass.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// constexpr bool optional<T>::has_value() const noexcept; - -#include <optional> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -int main() -{ - using std::optional; - { - const optional<int> opt; ((void)opt); - ASSERT_NOEXCEPT(opt.has_value()); - ASSERT_SAME_TYPE(decltype(opt.has_value()), bool); - } - { - constexpr optional<int> opt; - static_assert(!opt.has_value(), ""); - } - { - constexpr optional<int> opt(0); - static_assert(opt.has_value(), ""); - } -} diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp deleted file mode 100644 index 2f1648c48c8..00000000000 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// constexpr T* optional<T>::operator->(); - -#ifdef _LIBCPP_DEBUG -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - -#include <optional> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -using std::optional; - -struct X -{ - int test() noexcept {return 3;} -}; - -struct Y -{ - constexpr int test() {return 3;} -}; - -constexpr int -test() -{ - optional<Y> opt{Y{}}; - return opt->test(); -} - -int main() -{ - { - std::optional<X> opt; ((void)opt); - ASSERT_SAME_TYPE(decltype(opt.operator->()), X*); - // ASSERT_NOT_NOEXCEPT(opt.operator->()); - // FIXME: This assertion fails with GCC because it can see that - // (A) operator->() is constexpr, and - // (B) there is no path through the function that throws. - // It's arguable if this is the correct behavior for the noexcept - // operator. - // Regardless this function should still be noexcept(false) because - // it has a narrow contract. - } - { - optional<X> opt(X{}); - assert(opt->test() == 3); - } - { - static_assert(test() == 3, ""); - } -#ifdef _LIBCPP_DEBUG - { - optional<X> opt; - assert(opt->test() == 3); - assert(false); - } -#endif // _LIBCPP_DEBUG -} diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp deleted file mode 100644 index 887edc7114e..00000000000 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp +++ /dev/null @@ -1,76 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// constexpr const T* optional<T>::operator->() const; - -#ifdef _LIBCPP_DEBUG -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - -#include <optional> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -using std::optional; - -struct X -{ - constexpr int test() const {return 3;} -}; - -struct Y -{ - int test() const noexcept {return 2;} -}; - -struct Z -{ - const Z* operator&() const; - constexpr int test() const {return 1;} -}; - -int main() -{ - { - const std::optional<X> opt; ((void)opt); - ASSERT_SAME_TYPE(decltype(opt.operator->()), X const*); - // ASSERT_NOT_NOEXCEPT(opt.operator->()); - // FIXME: This assertion fails with GCC because it can see that - // (A) operator->() is constexpr, and - // (B) there is no path through the function that throws. - // It's arguable if this is the correct behavior for the noexcept - // operator. - // Regardless this function should still be noexcept(false) because - // it has a narrow contract. - } - { - constexpr optional<X> opt(X{}); - static_assert(opt->test() == 3, ""); - } - { - constexpr optional<Y> opt(Y{}); - assert(opt->test() == 2); - } - { - constexpr optional<Z> opt(Z{}); - static_assert(opt->test() == 1, ""); - } -#ifdef _LIBCPP_DEBUG - { - const optional<X> opt; - assert(opt->test() == 3); - assert(false); - } -#endif // _LIBCPP_DEBUG -} diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value.pass.cpp deleted file mode 100644 index 516a79db5f6..00000000000 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value.pass.cpp +++ /dev/null @@ -1,73 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// constexpr T& optional<T>::value() &; - -#include <optional> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -using std::optional; -using std::bad_optional_access; - -struct X -{ - X() = default; - X(const X&) = delete; - constexpr int test() const & {return 3;} - int test() & {return 4;} - constexpr int test() const && {return 5;} - int test() && {return 6;} -}; - -struct Y -{ - constexpr int test() & {return 7;} -}; - -constexpr int -test() -{ - optional<Y> opt{Y{}}; - return opt.value().test(); -} - - -int main() -{ - { - optional<X> opt; ((void)opt); - ASSERT_NOT_NOEXCEPT(opt.value()); - ASSERT_SAME_TYPE(decltype(opt.value()), X&); - } - { - optional<X> opt; - opt.emplace(); - assert(opt.value().test() == 4); - } -#ifndef TEST_HAS_NO_EXCEPTIONS - { - optional<X> opt; - try - { - opt.value(); - assert(false); - } - catch (const bad_optional_access&) - { - } - } -#endif - static_assert(test() == 7, ""); -} diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_const.fail.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_const.fail.cpp deleted file mode 100644 index 6076c509fa4..00000000000 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_const.fail.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// constexpr const T& optional<T>::value() const &; - -#include <optional> -#include <type_traits> -#include <cassert> - -using std::optional; - -struct X -{ - constexpr int test() const {return 3;} - int test() {return 4;} -}; - -int main() -{ - { - constexpr optional<X> opt; - static_assert(opt.value().test() == 3, ""); - } -} diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_const.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_const.pass.cpp deleted file mode 100644 index d4038e4efa6..00000000000 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_const.pass.cpp +++ /dev/null @@ -1,64 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// constexpr const T& optional<T>::value() const &; - -#include <optional> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -using std::optional; -using std::in_place_t; -using std::in_place; -using std::bad_optional_access; - -struct X -{ - X() = default; - X(const X&) = delete; - constexpr int test() const & {return 3;} - int test() & {return 4;} - constexpr int test() const && {return 5;} - int test() && {return 6;} -}; - -int main() -{ - { - const optional<X> opt; ((void)opt); - ASSERT_NOT_NOEXCEPT(opt.value()); - ASSERT_SAME_TYPE(decltype(opt.value()), X const&); - } - { - constexpr optional<X> opt(in_place); - static_assert(opt.value().test() == 3, ""); - } - { - const optional<X> opt(in_place); - assert(opt.value().test() == 3); - } -#ifndef TEST_HAS_NO_EXCEPTIONS - { - const optional<X> opt; - try - { - opt.value(); - assert(false); - } - catch (const bad_optional_access&) - { - } - } -#endif -} diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_const_rvalue.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_const_rvalue.pass.cpp deleted file mode 100644 index e189d3af688..00000000000 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_const_rvalue.pass.cpp +++ /dev/null @@ -1,64 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// constexpr const T& optional<T>::value() const &&; - -#include <optional> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -using std::optional; -using std::in_place_t; -using std::in_place; -using std::bad_optional_access; - -struct X -{ - X() = default; - X(const X&) = delete; - constexpr int test() const & {return 3;} - int test() & {return 4;} - constexpr int test() const && {return 5;} - int test() && {return 6;} -}; - -int main() -{ - { - const optional<X> opt; ((void)opt); - ASSERT_NOT_NOEXCEPT(std::move(opt).value()); - ASSERT_SAME_TYPE(decltype(std::move(opt).value()), X const&&); - } - { - constexpr optional<X> opt(in_place); - static_assert(std::move(opt).value().test() == 5, ""); - } - { - const optional<X> opt(in_place); - assert(std::move(opt).value().test() == 5); - } -#ifndef TEST_HAS_NO_EXCEPTIONS - { - const optional<X> opt; - try - { - std::move(opt).value(); - assert(false); - } - catch (const bad_optional_access&) - { - } - } -#endif -} diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp deleted file mode 100644 index c219e970471..00000000000 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp +++ /dev/null @@ -1,68 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template <class U> T optional<T>::value_or(U&& v) &&; - -#include <optional> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -using std::optional; -using std::in_place_t; -using std::in_place; - -struct Y -{ - int i_; - - Y(int i) : i_(i) {} -}; - -struct X -{ - int i_; - - X(int i) : i_(i) {} - X(X&& x) : i_(x.i_) {x.i_ = 0;} - X(const Y& y) : i_(y.i_) {} - X(Y&& y) : i_(y.i_+1) {} - friend constexpr bool operator==(const X& x, const X& y) - {return x.i_ == y.i_;} -}; - -int main() -{ - { - optional<X> opt(in_place, 2); - Y y(3); - assert(std::move(opt).value_or(y) == 2); - assert(*opt == 0); - } - { - optional<X> opt(in_place, 2); - assert(std::move(opt).value_or(Y(3)) == 2); - assert(*opt == 0); - } - { - optional<X> opt; - Y y(3); - assert(std::move(opt).value_or(y) == 3); - assert(!opt); - } - { - optional<X> opt; - assert(std::move(opt).value_or(Y(3)) == 4); - assert(!opt); - } -} diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp deleted file mode 100644 index 36a85811ba4..00000000000 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp +++ /dev/null @@ -1,77 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template <class U> constexpr T optional<T>::value_or(U&& v) const&; - -#include <optional> -#include <type_traits> -#include <cassert> - -using std::optional; - -struct Y -{ - int i_; - - constexpr Y(int i) : i_(i) {} -}; - -struct X -{ - int i_; - - constexpr X(int i) : i_(i) {} - constexpr X(const Y& y) : i_(y.i_) {} - constexpr X(Y&& y) : i_(y.i_+1) {} - friend constexpr bool operator==(const X& x, const X& y) - {return x.i_ == y.i_;} -}; - -int main() -{ - { - constexpr optional<X> opt(2); - constexpr Y y(3); - static_assert(opt.value_or(y) == 2, ""); - } - { - constexpr optional<X> opt(2); - static_assert(opt.value_or(Y(3)) == 2, ""); - } - { - constexpr optional<X> opt; - constexpr Y y(3); - static_assert(opt.value_or(y) == 3, ""); - } - { - constexpr optional<X> opt; - static_assert(opt.value_or(Y(3)) == 4, ""); - } - { - const optional<X> opt(2); - const Y y(3); - assert(opt.value_or(y) == 2); - } - { - const optional<X> opt(2); - assert(opt.value_or(Y(3)) == 2); - } - { - const optional<X> opt; - const Y y(3); - assert(opt.value_or(y) == 3); - } - { - const optional<X> opt; - assert(opt.value_or(Y(3)) == 4); - } -} diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_rvalue.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_rvalue.pass.cpp deleted file mode 100644 index 2ef485b7fe5..00000000000 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_rvalue.pass.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// constexpr T& optional<T>::value() &&; - -#include <optional> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -using std::optional; -using std::bad_optional_access; - -struct X -{ - X() = default; - X(const X&) = delete; - constexpr int test() const & {return 3;} - int test() & {return 4;} - constexpr int test() const && {return 5;} - int test() && {return 6;} -}; - -struct Y -{ - constexpr int test() && {return 7;} -}; - -constexpr int -test() -{ - optional<Y> opt{Y{}}; - return std::move(opt).value().test(); -} - -int main() -{ - { - optional<X> opt; ((void)opt); - ASSERT_NOT_NOEXCEPT(std::move(opt).value()); - ASSERT_SAME_TYPE(decltype(std::move(opt).value()), X&&); - } - { - optional<X> opt; - opt.emplace(); - assert(std::move(opt).value().test() == 6); - } -#ifndef TEST_HAS_NO_EXCEPTIONS - { - optional<X> opt; - try - { - std::move(opt).value(); - assert(false); - } - catch (const bad_optional_access&) - { - } - } -#endif - static_assert(test() == 7, ""); -} |