aboutsummaryrefslogtreecommitdiff
path: root/test/std/experimental/optional/optional.object/optional.object.ctor
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/experimental/optional/optional.object/optional.object.ctor')
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp116
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp139
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/default.pass.cpp62
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp144
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp118
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp149
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp63
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp110
8 files changed, 0 insertions, 901 deletions
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
deleted file mode 100644
index 6371dcb4e51c..000000000000
--- a/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
+++ /dev/null
@@ -1,116 +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>
-
-// constexpr optional(const T& v);
-
-#include <experimental/optional>
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-
-using std::experimental::optional;
-
-class X
-{
- int i_;
-public:
- X(int i) : i_(i) {}
-
- friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
-};
-
-class Y
-{
- int i_;
-public:
- constexpr Y(int i) : i_(i) {}
-
- friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
-};
-
-class Z
-{
-public:
- Z(int) {}
- Z(const Z&) {TEST_THROW(6);}
-};
-
-
-int main()
-{
- {
- typedef int T;
- constexpr T t(5);
- constexpr optional<T> opt(t);
- static_assert(static_cast<bool>(opt) == true, "");
- static_assert(*opt == 5, "");
-
- struct test_constexpr_ctor
- : public optional<T>
- {
- constexpr test_constexpr_ctor(const T&) {}
- };
-
- }
- {
- typedef double T;
- constexpr T t(3);
- constexpr optional<T> opt(t);
- static_assert(static_cast<bool>(opt) == true, "");
- static_assert(*opt == 3, "");
-
- struct test_constexpr_ctor
- : public optional<T>
- {
- constexpr test_constexpr_ctor(const T&) {}
- };
-
- }
- {
- typedef X T;
- const T t(3);
- optional<T> opt(t);
- assert(static_cast<bool>(opt) == true);
- assert(*opt == 3);
- }
- {
- typedef Y T;
- constexpr T t(3);
- constexpr optional<T> opt(t);
- static_assert(static_cast<bool>(opt) == true, "");
- static_assert(*opt == 3, "");
-
- struct test_constexpr_ctor
- : public optional<T>
- {
- constexpr test_constexpr_ctor(const T&) {}
- };
-
- }
-#ifndef TEST_HAS_NO_EXCEPTIONS
- {
- typedef Z T;
- try
- {
- const T t(3);
- optional<T> opt(t);
- assert(false);
- }
- catch (int i)
- {
- assert(i == 6);
- }
- }
-#endif
-}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp
deleted file mode 100644
index 4b66fe80bbb2..000000000000
--- a/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp
+++ /dev/null
@@ -1,139 +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>
-
-// optional(const optional<T>& rhs);
-
-#include <experimental/optional>
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-
-using std::experimental::optional;
-
-template <class T>
-void
-test(const optional<T>& rhs, bool is_going_to_throw = false)
-{
- bool rhs_engaged = static_cast<bool>(rhs);
-#ifdef TEST_HAS_NO_EXCEPTIONS
- if (is_going_to_throw)
- return;
-#else
- try
-#endif
- {
- optional<T> lhs = rhs;
- assert(is_going_to_throw == false);
- assert(static_cast<bool>(lhs) == rhs_engaged);
- if (rhs_engaged)
- assert(*lhs == *rhs);
- }
-#ifndef TEST_HAS_NO_EXCEPTIONS
- catch (int i)
- {
- assert(i == 6);
- assert(is_going_to_throw);
- }
-#endif
-}
-
-class X
-{
- int i_;
-public:
- X(int i) : i_(i) {}
- X(const X& x) : i_(x.i_) {}
- ~X() {i_ = 0;}
- friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
-};
-
-class Y
-{
- int i_;
-public:
- Y(int i) : i_(i) {}
- Y(const Y& x) : i_(x.i_) {}
-
- friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
-};
-
-int count = 0;
-
-class Z
-{
- int i_;
-public:
- Z(int i) : i_(i) {}
- Z(const Z&)
- {
- if (++count == 2)
- TEST_THROW(6);
- }
-
- friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
-};
-
-
-int main()
-{
- {
- typedef int T;
- optional<T> rhs;
- test(rhs);
- }
- {
- typedef int T;
- optional<T> rhs(3);
- test(rhs);
- }
- {
- typedef const int T;
- optional<T> rhs(3);
- test(rhs);
- }
- {
- typedef X T;
- optional<T> rhs;
- test(rhs);
- }
- {
- typedef X T;
- optional<T> rhs(X(3));
- test(rhs);
- }
- {
- typedef const X T;
- optional<T> rhs(X(3));
- test(rhs);
- }
- {
- typedef Y T;
- optional<T> rhs;
- test(rhs);
- }
- {
- typedef Y T;
- optional<T> rhs(Y(3));
- test(rhs);
- }
- {
- typedef Z T;
- optional<T> rhs;
- test(rhs);
- }
- {
- typedef Z T;
- optional<T> rhs(Z(3));
- test(rhs, true);
- }
-}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/default.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/default.pass.cpp
deleted file mode 100644
index d24a1ac69b86..000000000000
--- a/test/std/experimental/optional/optional.object/optional.object.ctor/default.pass.cpp
+++ /dev/null
@@ -1,62 +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>
-
-// constexpr optional() noexcept;
-
-#include <experimental/optional>
-#include <type_traits>
-#include <cassert>
-
-using std::experimental::optional;
-
-template <class Opt>
-void
-test_constexpr()
-{
- static_assert(std::is_nothrow_default_constructible<Opt>::value, "");
- constexpr Opt opt;
- static_assert(static_cast<bool>(opt) == false, "");
-
- struct test_constexpr_ctor
- : public Opt
- {
- constexpr test_constexpr_ctor() {}
- };
-
-}
-
-template <class Opt>
-void
-test()
-{
- static_assert(std::is_nothrow_default_constructible<Opt>::value, "");
- Opt opt;
- assert(static_cast<bool>(opt) == false);
-
- struct test_constexpr_ctor
- : public Opt
- {
- constexpr test_constexpr_ctor() {}
- };
-}
-
-struct X
-{
- X();
-};
-
-int main()
-{
- test_constexpr<optional<int>>();
- test_constexpr<optional<int*>>();
- test<optional<X>>();
-}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
deleted file mode 100644
index c46407896576..000000000000
--- a/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
+++ /dev/null
@@ -1,144 +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>
-// constexpr explicit optional(in_place_t, Args&&... args);
-
-#include <experimental/optional>
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-
-using std::experimental::optional;
-using std::experimental::in_place_t;
-using std::experimental::in_place;
-
-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) {}
-
- ~X() {}
-
- friend bool operator==(const X& x, const X& y)
- {return x.i_ == y.i_ && x.j_ == y.j_;}
-};
-
-class Y
-{
- int i_;
- int j_ = 0;
-public:
- constexpr Y() : i_(0) {}
- constexpr Y(int i) : i_(i) {}
- constexpr Y(int i, int j) : i_(i), j_(j) {}
-
- friend constexpr bool operator==(const Y& x, const Y& y)
- {return x.i_ == y.i_ && x.j_ == y.j_;}
-};
-
-class Z
-{
-public:
- Z(int) {TEST_THROW(6);}
-};
-
-
-int main()
-{
- {
- constexpr optional<int> opt(in_place, 5);
- static_assert(static_cast<bool>(opt) == true, "");
- static_assert(*opt == 5, "");
-
- struct test_constexpr_ctor
- : public optional<int>
- {
- constexpr test_constexpr_ctor(in_place_t, int i)
- : optional<int>(in_place, i) {}
- };
-
- }
- {
- const optional<X> opt(in_place);
- assert(static_cast<bool>(opt) == true);
- assert(*opt == X());
- }
- {
- const optional<X> opt(in_place, 5);
- assert(static_cast<bool>(opt) == true);
- assert(*opt == X(5));
- }
- {
- const optional<X> opt(in_place, 5, 4);
- assert(static_cast<bool>(opt) == true);
- assert(*opt == X(5, 4));
- }
- {
- constexpr optional<Y> opt(in_place);
- static_assert(static_cast<bool>(opt) == true, "");
- static_assert(*opt == Y(), "");
-
- struct test_constexpr_ctor
- : public optional<Y>
- {
- constexpr test_constexpr_ctor(in_place_t)
- : optional<Y>(in_place) {}
- };
-
- }
- {
- constexpr optional<Y> opt(in_place, 5);
- static_assert(static_cast<bool>(opt) == true, "");
- static_assert(*opt == Y(5), "");
-
- struct test_constexpr_ctor
- : public optional<Y>
- {
- constexpr test_constexpr_ctor(in_place_t, int i)
- : optional<Y>(in_place, i) {}
- };
-
- }
- {
- constexpr optional<Y> opt(in_place, 5, 4);
- static_assert(static_cast<bool>(opt) == true, "");
- static_assert(*opt == Y(5, 4), "");
-
- struct test_constexpr_ctor
- : public optional<Y>
- {
- constexpr test_constexpr_ctor(in_place_t, int i, int j)
- : optional<Y>(in_place, i, j) {}
- };
-
- }
-#ifndef TEST_HAS_NO_EXCEPTIONS
- {
- try
- {
- const optional<Z> opt(in_place, 1);
- assert(false);
- }
- catch (int i)
- {
- assert(i == 6);
- }
- }
-#endif
-}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
deleted file mode 100644
index b75c147df513..000000000000
--- a/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
+++ /dev/null
@@ -1,118 +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 U, class... Args>
-// constexpr
-// explicit optional(in_place_t, initializer_list<U> il, Args&&... args);
-
-#include <experimental/optional>
-#include <type_traits>
-#include <vector>
-#include <cassert>
-
-#include "test_macros.h"
-
-using std::experimental::optional;
-using std::experimental::in_place_t;
-using std::experimental::in_place;
-
-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) {}
-
- ~X() {}
-
- friend bool operator==(const X& x, const X& y)
- {return x.i_ == y.i_ && x.j_ == y.j_;}
-};
-
-class Y
-{
- int i_;
- int j_ = 0;
-public:
- constexpr Y() : i_(0) {}
- constexpr Y(int i) : i_(i) {}
- constexpr Y(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1]) {}
-
- friend constexpr bool operator==(const Y& x, const Y& y)
- {return x.i_ == y.i_ && x.j_ == y.j_;}
-};
-
-class Z
-{
- int i_;
- int j_ = 0;
-public:
- constexpr Z() : i_(0) {}
- constexpr Z(int i) : i_(i) {}
- Z(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1])
- {TEST_THROW(6);}
-
- friend constexpr bool operator==(const Z& x, const Z& y)
- {return x.i_ == y.i_ && x.j_ == y.j_;}
-};
-
-int main()
-{
- {
- static_assert(!std::is_constructible<X, std::initializer_list<int>&>::value, "");
- static_assert(!std::is_constructible<optional<X>, std::initializer_list<int>&>::value, "");
- }
- {
- optional<std::vector<int>> opt(in_place, {3, 1});
- assert(static_cast<bool>(opt) == true);
- assert((*opt == std::vector<int>{3, 1}));
- assert(opt->size() == 2);
- }
- {
- optional<std::vector<int>> opt(in_place, {3, 1}, std::allocator<int>());
- assert(static_cast<bool>(opt) == true);
- assert((*opt == std::vector<int>{3, 1}));
- assert(opt->size() == 2);
- }
- {
- static_assert(std::is_constructible<optional<Y>, std::initializer_list<int>&>::value, "");
- constexpr optional<Y> opt(in_place, {3, 1});
- static_assert(static_cast<bool>(opt) == true, "");
- static_assert(*opt == Y{3, 1}, "");
-
- struct test_constexpr_ctor
- : public optional<Y>
- {
- constexpr test_constexpr_ctor(in_place_t, std::initializer_list<int> i)
- : optional<Y>(in_place, i) {}
- };
-
- constexpr test_constexpr_ctor dopt(in_place, {42, 101, -1});
- static_assert(*dopt == Y{42, 101, -1}, "");
- }
-#ifndef TEST_HAS_NO_EXCEPTIONS
- {
- static_assert(std::is_constructible<optional<Z>, std::initializer_list<int>&>::value, "");
- try
- {
- optional<Z> opt(in_place, {3, 1});
- assert(false);
- }
- catch (int i)
- {
- assert(i == 6);
- }
- }
-#endif
-}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
deleted file mode 100644
index a8bb6e9c275c..000000000000
--- a/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ /dev/null
@@ -1,149 +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>
-
-// optional(optional<T>&& rhs) noexcept(is_nothrow_move_constructible<T>::value);
-
-#include <experimental/optional>
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-
-using std::experimental::optional;
-
-template <class T>
-void
-test(optional<T>& rhs, bool is_going_to_throw = false)
-{
- static_assert(std::is_nothrow_move_constructible<optional<T>>::value ==
- std::is_nothrow_move_constructible<T>::value, "");
- bool rhs_engaged = static_cast<bool>(rhs);
-#ifdef TEST_HAS_NO_EXCEPTIONS
- if (is_going_to_throw)
- return;
-#else
- try
-#endif
- {
- optional<T> lhs = std::move(rhs);
- assert(is_going_to_throw == false);
- assert(static_cast<bool>(lhs) == rhs_engaged);
- }
-#ifndef TEST_HAS_NO_EXCEPTIONS
- catch (int i)
- {
- assert(i == 6);
- assert(is_going_to_throw);
- }
-#endif
-}
-
-class X
-{
- int i_;
-public:
- X(int i) : i_(i) {}
- X(X&& x) : i_(x.i_) {x.i_ = 0;}
- ~X() {i_ = 0;}
- friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
-};
-
-class Y
-{
- int i_;
-public:
- Y(int i) : i_(i) {}
- Y(Y&& x) noexcept : i_(x.i_) {x.i_ = 0;}
-
- friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
-};
-
-int count = 0;
-
-class Z
-{
- int i_;
-public:
- Z(int i) : i_(i) {}
- Z(Z&&)
- {
- if (++count == 2)
- TEST_THROW(6);
- }
-
- friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
-};
-
-
-class ConstMovable
-{
- int i_;
-public:
- ConstMovable(int i) : i_(i) {}
- ConstMovable(const ConstMovable&& x) : i_(x.i_) {}
- ~ConstMovable() {i_ = 0;}
- friend bool operator==(const ConstMovable& x, const ConstMovable& y) {return x.i_ == y.i_;}
-};
-
-int main()
-{
- {
- typedef int T;
- optional<T> rhs;
- test(rhs);
- }
- {
- typedef int T;
- optional<T> rhs(3);
- test(rhs);
- }
- {
- typedef const int T;
- optional<T> rhs(3);
- test(rhs);
- }
- {
- typedef X T;
- optional<T> rhs;
- test(rhs);
- }
- {
- typedef X T;
- optional<T> rhs(X(3));
- test(rhs);
- }
- {
- typedef const ConstMovable T;
- optional<T> rhs(ConstMovable(3));
- test(rhs);
- }
- {
- typedef Y T;
- optional<T> rhs;
- test(rhs);
- }
- {
- typedef Y T;
- optional<T> rhs(Y(3));
- test(rhs);
- }
- {
- typedef Z T;
- optional<T> rhs;
- test(rhs);
- }
- {
- typedef Z T;
- optional<T> rhs(Z(3));
- test(rhs, true);
- }
-}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp
deleted file mode 100644
index 40c96581ed84..000000000000
--- a/test/std/experimental/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp
+++ /dev/null
@@ -1,63 +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>
-
-// constexpr optional(nullopt_t) noexcept;
-
-#include <experimental/optional>
-#include <type_traits>
-#include <cassert>
-
-using std::experimental::optional;
-using std::experimental::nullopt_t;
-using std::experimental::nullopt;
-
-template <class Opt>
-void
-test_constexpr()
-{
- static_assert(noexcept(Opt(nullopt)), "");
- constexpr Opt opt(nullopt);
- static_assert(static_cast<bool>(opt) == false, "");
-
- struct test_constexpr_ctor
- : public Opt
- {
- constexpr test_constexpr_ctor() {}
- };
-}
-
-template <class Opt>
-void
-test()
-{
- static_assert(noexcept(Opt(nullopt)), "");
- Opt opt(nullopt);
- assert(static_cast<bool>(opt) == false);
-
- struct test_constexpr_ctor
- : public Opt
- {
- constexpr test_constexpr_ctor() {}
- };
-}
-
-struct X
-{
- X();
-};
-
-int main()
-{
- test_constexpr<optional<int>>();
- test_constexpr<optional<int*>>();
- test<optional<X>>();
-}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
deleted file mode 100644
index 1941546a53f7..000000000000
--- a/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
+++ /dev/null
@@ -1,110 +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>
-
-// constexpr optional(T&& v);
-
-#include <experimental/optional>
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-
-using std::experimental::optional;
-
-class X
-{
- int i_;
-public:
- X(int i) : i_(i) {}
- X(X&& x) : i_(x.i_) {}
-
- friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
-};
-
-class Y
-{
- int i_;
-public:
- constexpr Y(int i) : i_(i) {}
- constexpr Y(Y&& x) : i_(x.i_) {}
-
- friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
-};
-
-class Z
-{
-public:
- Z(int) {}
- Z(Z&&) {TEST_THROW(6);}
-};
-
-
-int main()
-{
- {
- typedef int T;
- constexpr optional<T> opt(T(5));
- static_assert(static_cast<bool>(opt) == true, "");
- static_assert(*opt == 5, "");
-
- struct test_constexpr_ctor
- : public optional<T>
- {
- constexpr test_constexpr_ctor(T&&) {}
- };
- }
- {
- typedef double T;
- constexpr optional<T> opt(T(3));
- static_assert(static_cast<bool>(opt) == true, "");
- static_assert(*opt == 3, "");
-
- struct test_constexpr_ctor
- : public optional<T>
- {
- constexpr test_constexpr_ctor(T&&) {}
- };
- }
- {
- typedef X T;
- optional<T> opt(T(3));
- assert(static_cast<bool>(opt) == true);
- assert(*opt == 3);
- }
- {
- typedef Y T;
- constexpr optional<T> opt(T(3));
- static_assert(static_cast<bool>(opt) == true, "");
- static_assert(*opt == 3, "");
-
- struct test_constexpr_ctor
- : public optional<T>
- {
- constexpr test_constexpr_ctor(T&&) {}
- };
- }
-#ifndef TEST_HAS_NO_EXCEPTIONS
- {
- typedef Z T;
- try
- {
- optional<T> opt(T(3));
- assert(false);
- }
- catch (int i)
- {
- assert(i == 6);
- }
- }
-#endif
-}