summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2018-02-01 14:54:25 +0000
committerMarshall Clow <mclow.lists@gmail.com>2018-02-01 14:54:25 +0000
commit040533215adb65f20380f6e94dc03acf25c60371 (patch)
tree472e1c0cb077e8c1608a14d43b351cd94490b774 /libcxx/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
parentafc7c63bc2beb6fa9c0366bbb1664fdc39222c5f (diff)
downloadbcm5719-llvm-040533215adb65f20380f6e94dc03acf25c60371.tar.gz
bcm5719-llvm-040533215adb65f20380f6e94dc03acf25c60371.zip
Remove <experimental/optional>; use <optional> instead. See https://libcxx.llvm.org/TS_deprecation.html
llvm-svn: 323971
Diffstat (limited to 'libcxx/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp')
-rw-r--r--libcxx/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp153
1 files changed, 0 insertions, 153 deletions
diff --git a/libcxx/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp b/libcxx/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
deleted file mode 100644
index 256396094a9..00000000000
--- a/libcxx/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
+++ /dev/null
@@ -1,153 +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
-// <optional>
-
-// template <class... Args> void optional<T>::emplace(Args&&... args);
-
-#include <experimental/optional>
-#include <type_traits>
-#include <cassert>
-#include <memory>
-
-#include "test_macros.h"
-
-using std::experimental::optional;
-
-class X
-{
- int i_;
- int j_ = 0;
-public:
- X() : i_(0) {}
- X(int i) : i_(i) {}
- X(int i, int j) : i_(i), j_(j) {}
-
- friend bool operator==(const X& x, const X& y)
- {return x.i_ == y.i_ && x.j_ == y.j_;}
-};
-
-class Y
-{
-public:
- static bool dtor_called;
- Y() = default;
- ~Y() {dtor_called = true;}
-};
-
-bool Y::dtor_called = false;
-
-class Z
-{
-public:
- static bool dtor_called;
- Z() = default;
- Z(int) {TEST_THROW(6);}
- ~Z() {dtor_called = true;}
-};
-
-bool Z::dtor_called = false;
-
-int main()
-{
- {
- optional<int> opt;
- opt.emplace();
- assert(static_cast<bool>(opt) == true);
- assert(*opt == 0);
- }
- {
- optional<int> opt;
- opt.emplace(1);
- assert(static_cast<bool>(opt) == true);
- assert(*opt == 1);
- }
- {
- optional<int> opt(2);
- opt.emplace();
- assert(static_cast<bool>(opt) == true);
- assert(*opt == 0);
- }
- {
- optional<int> opt(2);
- opt.emplace(1);
- assert(static_cast<bool>(opt) == true);
- assert(*opt == 1);
- }
- {
- optional<const int> opt(2);
- opt.emplace(1);
- assert(static_cast<bool>(opt) == true);
- assert(*opt == 1);
- }
- {
- optional<X> opt;
- opt.emplace();
- assert(static_cast<bool>(opt) == true);
- assert(*opt == X());
- }
- {
- optional<X> opt;
- opt.emplace(1);
- assert(static_cast<bool>(opt) == true);
- assert(*opt == X(1));
- }
- {
- optional<X> opt;
- opt.emplace(1, 2);
- assert(static_cast<bool>(opt) == true);
- assert(*opt == X(1, 2));
- }
- {
- optional<X> opt(X{3});
- opt.emplace();
- assert(static_cast<bool>(opt) == true);
- assert(*opt == X());
- }
- {
- optional<X> opt(X{3});
- opt.emplace(1);
- assert(static_cast<bool>(opt) == true);
- assert(*opt == X(1));
- }
- {
- optional<X> opt(X{3});
- opt.emplace(1, 2);
- assert(static_cast<bool>(opt) == true);
- assert(*opt == X(1, 2));
- }
- {
- Y y;
- {
- optional<Y> opt(y);
- assert(Y::dtor_called == false);
- opt.emplace();
- assert(Y::dtor_called == true);
- }
- }
-#ifndef TEST_HAS_NO_EXCEPTIONS
- {
- Z z;
- optional<Z> opt(z);
- try
- {
- assert(static_cast<bool>(opt) == true);
- assert(Z::dtor_called == false);
- opt.emplace(1);
- }
- catch (int i)
- {
- assert(i == 6);
- assert(static_cast<bool>(opt) == false);
- assert(Z::dtor_called == true);
- }
- }
-#endif
-}
OpenPOWER on IntegriCloud