aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libstdc++-v3/testsuite/experimental/optional
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/libstdc++-v3/testsuite/experimental/optional')
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/1.cc195
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/2.cc193
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/3.cc158
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/4.cc158
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/5.cc66
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/6.cc83
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/copy.cc126
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/default.cc60
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/move.cc126
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/value.cc239
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/cons/default.cc42
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/cons/value.cc69
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/in_place.cc43
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/make_optional.cc33
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/nullopt.cc46
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/1.cc33
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/2.cc37
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/3.cc37
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/4.cc35
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/5.cc40
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/1.cc99
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/2.cc111
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/3.cc89
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/4.cc101
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/5.cc80
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/6.cc88
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/in_place.cc66
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/make_optional.cc31
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/nullopt.cc46
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/1.cc33
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/2.cc35
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/3.cc58
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/4.cc35
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/5.cc40
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/1.cc89
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/2.cc101
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/3.cc79
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/4.cc91
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/5.cc70
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/6.cc78
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/requirements.cc256
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/experimental/optional/swap/1.cc95
42 files changed, 3590 insertions, 0 deletions
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/1.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/1.cc
new file mode 100644
index 000000000..5a7041bf7
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/1.cc
@@ -0,0 +1,195 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct exception {};
+
+int counter = 0;
+
+struct mixin_counter
+{
+ mixin_counter() { ++counter; }
+ mixin_counter(mixin_counter const&) { ++counter; }
+ ~mixin_counter() { --counter; }
+};
+
+struct value_type : private mixin_counter
+{
+ enum state_type
+ {
+ zero,
+ moved_from,
+ throwing_construction,
+ throwing_copy,
+ throwing_copy_assignment,
+ throwing_move,
+ throwing_move_assignment,
+ threw,
+ };
+
+ value_type() = default;
+
+ explicit value_type(state_type state_)
+ : state(state_)
+ {
+ throw_if(throwing_construction);
+ }
+
+ value_type(value_type const& other)
+ : state(other.state)
+ {
+ throw_if(throwing_copy);
+ }
+
+ value_type&
+ operator=(value_type const& other)
+ {
+ state = other.state;
+ throw_if(throwing_copy_assignment);
+ return *this;
+ }
+
+ value_type(value_type&& other)
+ : state(other.state)
+ {
+ other.state = moved_from;
+ throw_if(throwing_move);
+ }
+
+ value_type&
+ operator=(value_type&& other)
+ {
+ state = other.state;
+ other.state = moved_from;
+ throw_if(throwing_move_assignment);
+ return *this;
+ }
+
+ void throw_if(state_type match)
+ {
+ if(state == match)
+ {
+ state = threw;
+ throw exception {};
+ }
+ }
+
+ state_type state = zero;
+};
+
+int main()
+{
+ using O = std::experimental::optional<value_type>;
+ using S = value_type::state_type;
+ auto const make = [](S s = S::zero) { return O { std::experimental::in_place, s }; };
+
+ enum outcome_type { nothrow, caught, bad_catch };
+
+ // Check copy/move assignment for disengaged optional
+
+ // From disengaged optional
+ {
+ O o;
+ VERIFY( !o );
+ O p;
+ o = p;
+ VERIFY( !o );
+ VERIFY( !p );
+ }
+
+ {
+ O o;
+ VERIFY( !o );
+ O p;
+ o = std::move(p);
+ VERIFY( !o );
+ VERIFY( !p );
+ }
+
+ {
+ O o;
+ VERIFY( !o );
+ o = {};
+ VERIFY( !o );
+ }
+
+ // From engaged optional
+ {
+ O o;
+ VERIFY( !o );
+ O p = make(S::throwing_copy_assignment);
+ o = p;
+ VERIFY( o && o->state == S::throwing_copy_assignment );
+ VERIFY( p && p->state == S::throwing_copy_assignment );
+ }
+
+ {
+ O o;
+ VERIFY( !o );
+ O p = make(S::throwing_move_assignment);
+ o = std::move(p);
+ VERIFY( o && o->state == S::throwing_move_assignment );
+ VERIFY( p && p->state == S::moved_from );
+ }
+
+ {
+ outcome_type outcome {};
+ O o;
+ VERIFY( !o );
+ O p = make(S::throwing_copy);
+
+ try
+ {
+ o = p;
+ }
+ catch(exception const&)
+ { outcome = caught; }
+ catch(...)
+ { outcome = bad_catch; }
+
+ VERIFY( outcome == caught );
+ VERIFY( !o );
+ VERIFY( p && p->state == S::throwing_copy );
+ }
+
+ {
+ outcome_type outcome {};
+ O o;
+ VERIFY( !o );
+ O p = make(S::throwing_move);
+
+ try
+ {
+ o = std::move(p);
+ }
+ catch(exception const&)
+ { outcome = caught; }
+ catch(...)
+ { outcome = bad_catch; }
+
+ VERIFY( outcome == caught );
+ VERIFY( !o );
+ VERIFY( p && p->state == S::moved_from );
+ }
+
+ VERIFY( counter == 0 );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/2.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/2.cc
new file mode 100644
index 000000000..c19943f1c
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/2.cc
@@ -0,0 +1,193 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct exception {};
+
+int counter = 0;
+
+struct mixin_counter
+{
+ mixin_counter() { ++counter; }
+ mixin_counter(mixin_counter const&) { ++counter; }
+ ~mixin_counter() { --counter; }
+};
+
+struct value_type : private mixin_counter
+{
+ enum state_type
+ {
+ zero,
+ moved_from,
+ throwing_construction,
+ throwing_copy,
+ throwing_copy_assignment,
+ throwing_move,
+ throwing_move_assignment,
+ threw,
+ };
+
+ value_type() = default;
+
+ explicit value_type(state_type state_)
+ : state(state_)
+ {
+ throw_if(throwing_construction);
+ }
+
+ value_type(value_type const& other)
+ : state(other.state)
+ {
+ throw_if(throwing_copy);
+ }
+
+ value_type&
+ operator=(value_type const& other)
+ {
+ state = other.state;
+ throw_if(throwing_copy_assignment);
+ return *this;
+ }
+
+ value_type(value_type&& other)
+ : state(other.state)
+ {
+ other.state = moved_from;
+ throw_if(throwing_move);
+ }
+
+ value_type&
+ operator=(value_type&& other)
+ {
+ state = other.state;
+ other.state = moved_from;
+ throw_if(throwing_move_assignment);
+ return *this;
+ }
+
+ void throw_if(state_type match)
+ {
+ if(state == match)
+ {
+ state = threw;
+ throw exception {};
+ }
+ }
+
+ state_type state = zero;
+};
+
+int main()
+{
+ using O = std::experimental::optional<value_type>;
+ using S = value_type::state_type;
+ auto const make = [](S s = S::zero) { return O { std::experimental::in_place, s }; };
+
+ enum outcome_type { nothrow, caught, bad_catch };
+
+ // Check copy/move assignment for engaged optional
+
+ // From disengaged optional
+ {
+ O o = make(S::zero);
+ VERIFY( o );
+ O p;
+ o = p;
+ VERIFY( !o );
+ VERIFY( !p );
+ }
+
+ {
+ O o = make(S::zero);
+ VERIFY( o );
+ O p;
+ o = std::move(p);
+ VERIFY( !o );
+ VERIFY( !p );
+ }
+
+ {
+ O o = make(S::zero);
+ VERIFY( o );
+ o = {};
+ VERIFY( !o );
+ }
+
+ // From engaged optional
+ {
+ O o = make(S::zero);
+ VERIFY( o );
+ O p = make(S::throwing_copy);
+ o = p;
+ VERIFY( o && o->state == S::throwing_copy);
+ VERIFY( p && p->state == S::throwing_copy);
+ }
+
+ {
+ O o = make(S::zero);
+ VERIFY( o );
+ O p = make(S::throwing_move);
+ o = std::move(p);
+ VERIFY( o && o->state == S::throwing_move);
+ VERIFY( p && p->state == S::moved_from);
+ }
+
+ {
+ outcome_type outcome {};
+ O o = make(S::zero);
+ VERIFY( o );
+ O p = make(S::throwing_copy_assignment);
+
+ try
+ {
+ o = p;
+ }
+ catch(exception const&)
+ { outcome = caught; }
+ catch(...)
+ { outcome = bad_catch; }
+
+ VERIFY( o && o->state == S::threw);
+ VERIFY( p && p->state == S::throwing_copy_assignment);
+ }
+
+ {
+ outcome_type outcome {};
+ O o = make(S::zero);
+ VERIFY( o );
+ O p = make(S::throwing_move_assignment);
+
+ try
+ {
+ o = std::move(p);
+ }
+ catch(exception const&)
+ { outcome = caught; }
+ catch(...)
+ { outcome = bad_catch; }
+
+ VERIFY( o && o->state == S::threw);
+ VERIFY( p && p->state == S::moved_from);
+ }
+
+ VERIFY( counter == 0 );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/3.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/3.cc
new file mode 100644
index 000000000..35d45bbb0
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/3.cc
@@ -0,0 +1,158 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct exception {};
+
+int counter = 0;
+
+struct mixin_counter
+{
+ mixin_counter() { ++counter; }
+ mixin_counter(mixin_counter const&) { ++counter; }
+ ~mixin_counter() { --counter; }
+};
+
+struct value_type : private mixin_counter
+{
+ enum state_type
+ {
+ zero,
+ moved_from,
+ throwing_construction,
+ throwing_copy,
+ throwing_copy_assignment,
+ throwing_move,
+ throwing_move_assignment,
+ threw,
+ };
+
+ value_type() = default;
+
+ explicit value_type(state_type state_)
+ : state(state_)
+ {
+ throw_if(throwing_construction);
+ }
+
+ value_type(value_type const& other)
+ : state(other.state)
+ {
+ throw_if(throwing_copy);
+ }
+
+ value_type&
+ operator=(value_type const& other)
+ {
+ state = other.state;
+ throw_if(throwing_copy_assignment);
+ return *this;
+ }
+
+ value_type(value_type&& other)
+ : state(other.state)
+ {
+ other.state = moved_from;
+ throw_if(throwing_move);
+ }
+
+ value_type&
+ operator=(value_type&& other)
+ {
+ state = other.state;
+ other.state = moved_from;
+ throw_if(throwing_move_assignment);
+ return *this;
+ }
+
+ void throw_if(state_type match)
+ {
+ if(state == match)
+ {
+ state = threw;
+ throw exception {};
+ }
+ }
+
+ state_type state = zero;
+};
+
+int main()
+{
+ using O = std::experimental::optional<value_type>;
+ using S = value_type::state_type;
+ auto const make = [](S s = S::zero) { return value_type { s }; };
+
+ enum outcome_type { nothrow, caught, bad_catch };
+
+ // Check value assignment for disengaged optional
+
+ {
+ O o;
+ value_type v = make(S::throwing_copy_assignment);
+ o = v;
+ VERIFY( o && o->state == S::throwing_copy_assignment );
+ }
+
+ {
+ O o;
+ value_type v = make(S::throwing_move_assignment);
+ o = std::move(v);
+ VERIFY( o && o->state == S::throwing_move_assignment );
+ }
+
+ {
+ outcome_type outcome {};
+ O o;
+ value_type v = make(S::throwing_copy);
+
+ try
+ {
+ o = v;
+ }
+ catch(exception const&)
+ { outcome = caught; }
+ catch(...)
+ { outcome = bad_catch; }
+
+ VERIFY( !o );
+ }
+
+ {
+ outcome_type outcome {};
+ O o;
+ value_type v = make(S::throwing_move);
+
+ try
+ {
+ o = std::move(v);
+ }
+ catch(exception const&)
+ { outcome = caught; }
+ catch(...)
+ { outcome = bad_catch; }
+
+ VERIFY( !o );
+ }
+
+ VERIFY( counter == 0 );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/4.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/4.cc
new file mode 100644
index 000000000..8aec8ab0a
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/4.cc
@@ -0,0 +1,158 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct exception {};
+
+int counter = 0;
+
+struct mixin_counter
+{
+ mixin_counter() { ++counter; }
+ mixin_counter(mixin_counter const&) { ++counter; }
+ ~mixin_counter() { --counter; }
+};
+
+struct value_type : private mixin_counter
+{
+ enum state_type
+ {
+ zero,
+ moved_from,
+ throwing_construction,
+ throwing_copy,
+ throwing_copy_assignment,
+ throwing_move,
+ throwing_move_assignment,
+ threw,
+ };
+
+ value_type() = default;
+
+ explicit value_type(state_type state_)
+ : state(state_)
+ {
+ throw_if(throwing_construction);
+ }
+
+ value_type(value_type const& other)
+ : state(other.state)
+ {
+ throw_if(throwing_copy);
+ }
+
+ value_type&
+ operator=(value_type const& other)
+ {
+ state = other.state;
+ throw_if(throwing_copy_assignment);
+ return *this;
+ }
+
+ value_type(value_type&& other)
+ : state(other.state)
+ {
+ other.state = moved_from;
+ throw_if(throwing_move);
+ }
+
+ value_type&
+ operator=(value_type&& other)
+ {
+ state = other.state;
+ other.state = moved_from;
+ throw_if(throwing_move_assignment);
+ return *this;
+ }
+
+ void throw_if(state_type match)
+ {
+ if(state == match)
+ {
+ state = threw;
+ throw exception {};
+ }
+ }
+
+ state_type state = zero;
+};
+
+int main()
+{
+ using O = std::experimental::optional<value_type>;
+ using S = value_type::state_type;
+ auto const make = [](S s = S::zero) { return value_type { s }; };
+
+ enum outcome_type { nothrow, caught, bad_catch };
+
+ // Check value assignment for engaged optional
+
+ {
+ O o = make();
+ value_type v = make(S::throwing_copy);
+ o = v;
+ VERIFY( o && o->state == S::throwing_copy);
+ }
+
+ {
+ O o = make();
+ value_type v = make(S::throwing_move);
+ o = std::move(v);
+ VERIFY( o && o->state == S::throwing_move);
+ }
+
+ {
+ outcome_type outcome {};
+ O o = make();
+ value_type v = make(S::throwing_copy_assignment);
+
+ try
+ {
+ o = v;
+ }
+ catch(exception const&)
+ { outcome = caught; }
+ catch(...)
+ { outcome = bad_catch; }
+
+ VERIFY( o && o->state == S::threw );
+ }
+
+ {
+ outcome_type outcome {};
+ O o = make();
+ value_type v = make(S::throwing_move_assignment);
+
+ try
+ {
+ o = std::move(v);
+ }
+ catch(exception const&)
+ { outcome = caught; }
+ catch(...)
+ { outcome = bad_catch; }
+
+ VERIFY( o && o->state == S::threw );
+ }
+
+ VERIFY( counter == 0 );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/5.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/5.cc
new file mode 100644
index 000000000..b7dff41c9
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/5.cc
@@ -0,0 +1,66 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+int counter = 0;
+
+struct mixin_counter
+{
+ mixin_counter() { ++counter; }
+ mixin_counter(mixin_counter const&) { ++counter; }
+ ~mixin_counter() { --counter; }
+};
+
+struct value_type : private mixin_counter { };
+
+int main()
+{
+ using O = std::experimental::optional<value_type>;
+
+ // Check std::experimental::nullopt_t and 'default' (= {}) assignment
+
+ {
+ O o;
+ o = std::experimental::nullopt;
+ VERIFY( !o );
+ }
+
+ {
+ O o { std::experimental::in_place };
+ o = std::experimental::nullopt;
+ VERIFY( !o );
+ }
+
+ {
+ O o;
+ o = {};
+ VERIFY( !o );
+ }
+
+ {
+ O o { std::experimental::in_place };
+ o = {};
+ VERIFY( !o );
+ }
+
+ VERIFY( counter == 0 );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/6.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/6.cc
new file mode 100644
index 000000000..6418ab4aa
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/assignment/6.cc
@@ -0,0 +1,83 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+int counter = 0;
+
+struct mixin_counter
+{
+ mixin_counter() { ++counter; }
+ mixin_counter(mixin_counter const&) { ++counter; }
+ ~mixin_counter() { --counter; }
+};
+
+struct value_type : private mixin_counter
+{
+ value_type() = default;
+ value_type(int) : state(1) { }
+ value_type(std::initializer_list<char>, const char*) : state(2) { }
+ int state = 0;
+};
+
+int main()
+{
+ using O = std::experimental::optional<value_type>;
+
+ // Check emplace
+
+ {
+ O o;
+ o.emplace();
+ VERIFY( o && o->state == 0 );
+ }
+ {
+ O o { std::experimental::in_place, 0 };
+ o.emplace();
+ VERIFY( o && o->state == 0 );
+ }
+
+ {
+ O o;
+ o.emplace(0);
+ VERIFY( o && o->state == 1 );
+ }
+ {
+ O o { std::experimental::in_place };
+ o.emplace(0);
+ VERIFY( o && o->state == 1 );
+ }
+
+ {
+ O o;
+ o.emplace({ 'a' }, "");
+ VERIFY( o && o->state == 2 );
+ }
+ {
+ O o { std::experimental::in_place };
+ o.emplace({ 'a' }, "");
+ VERIFY( o && o->state == 2 );
+ }
+
+ static_assert( !std::is_constructible<O, std::initializer_list<int>, int>(), "" );
+
+ VERIFY( counter == 0 );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/copy.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/copy.cc
new file mode 100644
index 000000000..cd20634d1
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/copy.cc
@@ -0,0 +1,126 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct tracker
+{
+ tracker(int value) : value(value) { ++count; }
+ ~tracker() { --count; }
+
+ tracker(tracker const& other) : value(other.value) { ++count; }
+ tracker(tracker&& other) : value(other.value)
+ {
+ other.value = -1;
+ ++count;
+ }
+
+ tracker& operator=(tracker const&) = default;
+ tracker& operator=(tracker&&) = default;
+
+ int value;
+
+ static int count;
+};
+
+int tracker::count = 0;
+
+struct exception { };
+
+struct throwing_copy
+{
+ throwing_copy() = default;
+ throwing_copy(throwing_copy const&) { throw exception {}; }
+};
+
+int main()
+{
+ // [20.5.4.1] Constructors
+
+ {
+ std::experimental::optional<long> o;
+ auto copy = o;
+ VERIFY( !copy );
+ VERIFY( !o );
+ }
+
+ {
+ const long val = 0x1234ABCD;
+ std::experimental::optional<long> o { std::experimental::in_place, val};
+ auto copy = o;
+ VERIFY( copy );
+ VERIFY( *copy == val );
+ VERIFY( o && o == val );
+ }
+
+ {
+ std::experimental::optional<tracker> o;
+ auto copy = o;
+ VERIFY( !copy );
+ VERIFY( tracker::count == 0 );
+ VERIFY( !o );
+ }
+
+ {
+ std::experimental::optional<tracker> o { std::experimental::in_place, 333 };
+ auto copy = o;
+ VERIFY( copy );
+ VERIFY( copy->value == 333 );
+ VERIFY( tracker::count == 2 );
+ VERIFY( o && o->value == 333 );
+ }
+
+ enum outcome { nothrow, caught, bad_catch };
+
+ {
+ outcome result = nothrow;
+ std::experimental::optional<throwing_copy> o;
+
+ try
+ {
+ auto copy = o;
+ }
+ catch(exception const&)
+ { result = caught; }
+ catch(...)
+ { result = bad_catch; }
+
+ VERIFY( result == nothrow );
+ }
+
+ {
+ outcome result = nothrow;
+ std::experimental::optional<throwing_copy> o { std::experimental::in_place };
+
+ try
+ {
+ auto copy = o;
+ }
+ catch(exception const&)
+ { result = caught; }
+ catch(...)
+ { result = bad_catch; }
+
+ VERIFY( result == caught );
+ }
+
+ VERIFY( tracker::count == 0 );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/default.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/default.cc
new file mode 100644
index 000000000..2d118e361
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/default.cc
@@ -0,0 +1,60 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct tracker
+{
+ tracker() { ++count; }
+ ~tracker() { --count; }
+
+ tracker(tracker const&) { ++count; }
+ tracker(tracker&&) { ++count; }
+
+ tracker& operator=(tracker const&) = default;
+ tracker& operator=(tracker&&) = default;
+
+ static int count;
+};
+
+int tracker::count = 0;
+
+int main()
+{
+ // [20.5.4.1] Constructors
+
+ {
+ std::experimental::optional<tracker> o;
+ VERIFY( !o );
+ }
+
+ {
+ std::experimental::optional<tracker> o {};
+ VERIFY( !o );
+ }
+
+ {
+ std::experimental::optional<tracker> o = {};
+ VERIFY( !o );
+ }
+
+ VERIFY( tracker::count == 0 );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/move.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/move.cc
new file mode 100644
index 000000000..604bb58eb
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/move.cc
@@ -0,0 +1,126 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct tracker
+{
+ tracker(int value) : value(value) { ++count; }
+ ~tracker() { --count; }
+
+ tracker(tracker const& other) : value(other.value) { ++count; }
+ tracker(tracker&& other) : value(other.value)
+ {
+ other.value = -1;
+ ++count;
+ }
+
+ tracker& operator=(tracker const&) = default;
+ tracker& operator=(tracker&&) = default;
+
+ int value;
+
+ static int count;
+};
+
+int tracker::count = 0;
+
+struct exception { };
+
+struct throwing_move
+{
+ throwing_move() = default;
+ throwing_move(throwing_move const&) { throw exception {}; }
+};
+
+int main()
+{
+ // [20.5.4.1] Constructors
+
+ {
+ std::experimental::optional<long> o;
+ auto moved_to = std::move(o);
+ VERIFY( !moved_to );
+ VERIFY( !o );
+ }
+
+ {
+ const long val = 0x1234ABCD;
+ std::experimental::optional<long> o { std::experimental::in_place, val};
+ auto moved_to = std::move(o);
+ VERIFY( moved_to );
+ VERIFY( *moved_to == val );
+ VERIFY( o && *o == val );
+ }
+
+ {
+ std::experimental::optional<tracker> o;
+ auto moved_to = std::move(o);
+ VERIFY( !moved_to );
+ VERIFY( tracker::count == 0 );
+ VERIFY( !o );
+ }
+
+ {
+ std::experimental::optional<tracker> o { std::experimental::in_place, 333 };
+ auto moved_to = std::move(o);
+ VERIFY( moved_to );
+ VERIFY( moved_to->value == 333 );
+ VERIFY( tracker::count == 2 );
+ VERIFY( o && o->value == -1 );
+ }
+
+ enum outcome { nothrow, caught, bad_catch };
+
+ {
+ outcome result = nothrow;
+ std::experimental::optional<throwing_move> o;
+
+ try
+ {
+ auto moved_to = std::move(o);
+ }
+ catch(exception const&)
+ { result = caught; }
+ catch(...)
+ { result = bad_catch; }
+
+ VERIFY( result == nothrow );
+ }
+
+ {
+ outcome result = nothrow;
+ std::experimental::optional<throwing_move> o { std::experimental::in_place };
+
+ try
+ {
+ auto moved_to = std::move(o);
+ }
+ catch(exception const&)
+ { result = caught; }
+ catch(...)
+ { result = bad_catch; }
+
+ VERIFY( result == caught );
+ }
+
+ VERIFY( tracker::count == 0 );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/value.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/value.cc
new file mode 100644
index 000000000..68b088862
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/cons/value.cc
@@ -0,0 +1,239 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+#include <vector>
+
+struct tracker
+{
+ tracker(int value) : value(value) { ++count; }
+ ~tracker() { --count; }
+
+ tracker(tracker const& other) : value(other.value) { ++count; }
+ tracker(tracker&& other) : value(other.value)
+ {
+ other.value = -1;
+ ++count;
+ }
+
+ tracker& operator=(tracker const&) = default;
+ tracker& operator=(tracker&&) = default;
+
+ int value;
+
+ static int count;
+};
+
+int tracker::count = 0;
+
+struct exception { };
+
+struct throwing_construction
+{
+ explicit throwing_construction(bool propagate) : propagate(propagate) { }
+
+ throwing_construction(throwing_construction const& other)
+ : propagate(other.propagate)
+ {
+ if(propagate)
+ throw exception {};
+ }
+
+ bool propagate;
+};
+
+int main()
+{
+ // [20.5.4.1] Constructors
+
+ {
+ auto i = 0x1234ABCD;
+ std::experimental::optional<long> o { i };
+ VERIFY( o );
+ VERIFY( *o == 0x1234ABCD );
+ VERIFY( i == 0x1234ABCD );
+ }
+
+ {
+ auto i = 0x1234ABCD;
+ std::experimental::optional<long> o = i;
+ VERIFY( o );
+ VERIFY( *o == 0x1234ABCD );
+ VERIFY( i == 0x1234ABCD );
+ }
+
+ {
+ auto i = 0x1234ABCD;
+ std::experimental::optional<long> o = { i };
+ VERIFY( o );
+ VERIFY( *o == 0x1234ABCD );
+ VERIFY( i == 0x1234ABCD );
+ }
+
+ {
+ auto i = 0x1234ABCD;
+ std::experimental::optional<long> o { std::move(i) };
+ VERIFY( o );
+ VERIFY( *o == 0x1234ABCD );
+ VERIFY( i == 0x1234ABCD );
+ }
+
+ {
+ auto i = 0x1234ABCD;
+ std::experimental::optional<long> o = std::move(i);
+ VERIFY( o );
+ VERIFY( *o == 0x1234ABCD );
+ VERIFY( i == 0x1234ABCD );
+ }
+
+ {
+ auto i = 0x1234ABCD;
+ std::experimental::optional<long> o = { std::move(i) };
+ VERIFY( o );
+ VERIFY( *o == 0x1234ABCD );
+ VERIFY( i == 0x1234ABCD );
+ }
+
+ {
+ std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
+ std::experimental::optional<std::vector<int>> o { v };
+ VERIFY( !v.empty() );
+ VERIFY( o->size() == 6 );
+ }
+
+ {
+ std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
+ std::experimental::optional<std::vector<int>> o = v;
+ VERIFY( !v.empty() );
+ VERIFY( o->size() == 6 );
+ }
+
+ {
+ std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
+ std::experimental::optional<std::vector<int>> o { v };
+ VERIFY( !v.empty() );
+ VERIFY( o->size() == 6 );
+ }
+
+ {
+ std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
+ std::experimental::optional<std::vector<int>> o { std::move(v) };
+ VERIFY( v.empty() );
+ VERIFY( o->size() == 6 );
+ }
+
+ {
+ std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
+ std::experimental::optional<std::vector<int>> o = std::move(v);
+ VERIFY( v.empty() );
+ VERIFY( o->size() == 6 );
+ }
+
+ {
+ std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
+ std::experimental::optional<std::vector<int>> o { std::move(v) };
+ VERIFY( v.empty() );
+ VERIFY( o->size() == 6 );
+ }
+
+ {
+ tracker t { 333 };
+ std::experimental::optional<tracker> o = t;
+ VERIFY( o->value == 333 );
+ VERIFY( tracker::count == 2 );
+ VERIFY( t.value == 333 );
+ }
+
+ {
+ tracker t { 333 };
+ std::experimental::optional<tracker> o = std::move(t);
+ VERIFY( o->value == 333 );
+ VERIFY( tracker::count == 2 );
+ VERIFY( t.value == -1 );
+ }
+
+ enum outcome { nothrow, caught, bad_catch };
+
+ {
+ outcome result = nothrow;
+ throwing_construction t { false };
+
+ try
+ {
+ std::experimental::optional<throwing_construction> o { t };
+ }
+ catch(exception const&)
+ { result = caught; }
+ catch(...)
+ { result = bad_catch; }
+
+ VERIFY( result == nothrow );
+ }
+
+ {
+ outcome result = nothrow;
+ throwing_construction t { true };
+
+ try
+ {
+ std::experimental::optional<throwing_construction> o { t };
+ }
+ catch(exception const&)
+ { result = caught; }
+ catch(...)
+ { result = bad_catch; }
+
+ VERIFY( result == caught );
+ }
+
+ {
+ outcome result = nothrow;
+ throwing_construction t { false };
+
+ try
+ {
+ std::experimental::optional<throwing_construction> o { std::move(t) };
+ }
+ catch(exception const&)
+ { result = caught; }
+ catch(...)
+ { result = bad_catch; }
+
+ VERIFY( result == nothrow );
+ }
+
+ {
+ outcome result = nothrow;
+ throwing_construction t { true };
+
+ try
+ {
+ std::experimental::optional<throwing_construction> o { std::move(t) };
+ }
+ catch(exception const&)
+ { result = caught; }
+ catch(...)
+ { result = bad_catch; }
+
+ VERIFY( result == caught );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/cons/default.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/cons/default.cc
new file mode 100644
index 000000000..dbad2ae65
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/cons/default.cc
@@ -0,0 +1,42 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do compile }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ // [20.5.4.1] Constructors
+
+ {
+ constexpr std::experimental::optional<int> o;
+ static_assert( !o, "" );
+ }
+
+ {
+ constexpr std::experimental::optional<int> o {};
+ static_assert( !o, "" );
+ }
+
+ {
+ constexpr std::experimental::optional<int> o = {};
+ static_assert( !o, "" );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/cons/value.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/cons/value.cc
new file mode 100644
index 000000000..ade20b744
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/cons/value.cc
@@ -0,0 +1,69 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do compile }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ // [20.5.4.1] Constructors
+
+ {
+ constexpr long i = 0x1234ABCD;
+ constexpr std::experimental::optional<long> o { i };
+ static_assert( o, "" );
+ static_assert( *o == 0x1234ABCD, "" );
+ }
+
+ {
+ constexpr long i = 0x1234ABCD;
+ constexpr std::experimental::optional<long> o = i;
+ static_assert( o, "" );
+ static_assert( *o == 0x1234ABCD, "" );
+ }
+
+ {
+ constexpr long i = 0x1234ABCD;
+ constexpr std::experimental::optional<long> o = { i };
+ static_assert( o, "" );
+ static_assert( *o == 0x1234ABCD, "" );
+ }
+
+ {
+ constexpr long i = 0x1234ABCD;
+ constexpr std::experimental::optional<long> o { std::move(i) };
+ static_assert( o, "" );
+ static_assert( *o == 0x1234ABCD, "" );
+ }
+
+ {
+ constexpr long i = 0x1234ABCD;
+ constexpr std::experimental::optional<long> o = std::move(i);
+ static_assert( o, "" );
+ static_assert( *o == 0x1234ABCD, "" );
+ }
+
+ {
+ constexpr long i = 0x1234ABCD;
+ constexpr std::experimental::optional<long> o = { std::move(i) };
+ static_assert( o, "" );
+ static_assert( *o == 0x1234ABCD, "" );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/in_place.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/in_place.cc
new file mode 100644
index 000000000..05313f9e8
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/in_place.cc
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do compile }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ // [20.5.5] In-place construction
+ static_assert( std::is_same<decltype(std::experimental::in_place), const std::experimental::in_place_t>(), "" );
+ static_assert( std::is_empty<std::experimental::in_place_t>(), "" );
+
+ {
+ constexpr std::experimental::optional<int> o { std::experimental::in_place };
+ static_assert( o, "" );
+ static_assert( *o == int {}, "" );
+
+ static_assert( !std::is_convertible<std::experimental::in_place_t, std::experimental::optional<int>>(), "" );
+ }
+
+ {
+ constexpr std::experimental::optional<int> o { std::experimental::in_place, 42 };
+ static_assert( o, "" );
+ static_assert( *o == 42, "" );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/make_optional.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/make_optional.cc
new file mode 100644
index 000000000..fc45e2cbf
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/make_optional.cc
@@ -0,0 +1,33 @@
+// { dg-options "-std=gnu++1y" }
+// XFAIL pending resolution of PR libstdc++/58777
+// { dg-do compile { xfail *-*-* } }
+// { dg-excess-errors "" }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ constexpr int i = 42;
+ constexpr auto o = std::experimental::make_optional(i);
+ static_assert( std::is_same<decltype(o), const std::experimental::optional<int>>(), "" );
+ static_assert( o && *o == 42, "" );
+ static_assert( &*o != &i, "" );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/nullopt.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/nullopt.cc
new file mode 100644
index 000000000..6cd50dd82
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/nullopt.cc
@@ -0,0 +1,46 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do compile }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ // [20.5.6] Disengaged state indicator
+ static_assert( std::is_same<decltype(std::experimental::nullopt), const std::experimental::nullopt_t>(), "" );
+ static_assert( std::is_empty<std::experimental::nullopt_t>(), "" );
+ static_assert( std::is_literal_type<std::experimental::nullopt_t>(), "" );
+ static_assert( !std::is_default_constructible<std::experimental::nullopt_t>(), "" );
+
+ {
+ constexpr std::experimental::optional<int> o = std::experimental::nullopt;
+ static_assert( !o, "" );
+ }
+
+ {
+ constexpr std::experimental::optional<int> o = { std::experimental::nullopt };
+ static_assert( !o, "" );
+ }
+
+ {
+ constexpr std::experimental::optional<int> o { std::experimental::nullopt };
+ static_assert( !o, "" );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/1.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/1.cc
new file mode 100644
index 000000000..5aa2975ee
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/1.cc
@@ -0,0 +1,33 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do compile }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct value_type
+{
+ int i;
+};
+
+int main()
+{
+ constexpr std::experimental::optional<value_type> o { value_type { 51 } };
+ static_assert( (*o).i == 51, "" );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/2.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/2.cc
new file mode 100644
index 000000000..aa78d8add
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/2.cc
@@ -0,0 +1,37 @@
+// { dg-options "-std=gnu++1y" }
+// XFAIL pending resolution of PR libstdc++/58777
+// { dg-do compile { xfail *-*-* } }
+// { dg-excess-errors "" }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct value_type
+{
+ int i;
+};
+
+int main()
+{
+ constexpr std::experimental::optional<value_type> o { value_type { 51 } };
+ static_assert( o->i == 51, "" );
+ static_assert( o->i == (*o).i, "" );
+ static_assert( &o->i == &(*o).i, "" );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/3.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/3.cc
new file mode 100644
index 000000000..2fa84101d
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/3.cc
@@ -0,0 +1,37 @@
+// { dg-options "-std=gnu++1y" }
+// XFAIL pending resolution of PR libstdc++/58777
+// { dg-do compile { xfail *-*-* } }
+// { dg-excess-errors "" }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct value_type
+{
+ int i;
+};
+
+int main()
+{
+ constexpr std::experimental::optional<value_type> o { value_type { 51 } };
+ static_assert( o.value().i == 51, "" );
+ static_assert( o.value().i == (*o).i, "" );
+ static_assert( &o.value().i == &(*o).i, "" );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/4.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/4.cc
new file mode 100644
index 000000000..b40659e0c
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/4.cc
@@ -0,0 +1,35 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do compile }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct value_type
+{
+ int i;
+};
+
+int main()
+{
+ constexpr std::experimental::optional<value_type> o { value_type { 51 } };
+ constexpr value_type fallback { 3 };
+ static_assert( o.value_or(fallback).i == 51, "" );
+ static_assert( o.value_or(fallback).i == (*o).i, "" );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/5.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/5.cc
new file mode 100644
index 000000000..4214d76db
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/observers/5.cc
@@ -0,0 +1,40 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do compile }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct value_type
+{
+ int i;
+};
+
+int main()
+{
+ {
+ constexpr std::experimental::optional<value_type> o = std::experimental::nullopt;
+ static_assert( !o, "" );
+ }
+
+ {
+ constexpr std::experimental::optional<value_type> o { value_type { 51 } };
+ static_assert( o, "" );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/1.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/1.cc
new file mode 100644
index 000000000..d38a97ce4
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/1.cc
@@ -0,0 +1,99 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do compile }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+namespace ns
+{
+ struct value_type
+ {
+ int i;
+ const char* s;
+ };
+
+ constexpr bool
+ strcmp(const char* lhs, const char* rhs)
+ {
+ return *lhs == *rhs && (!*lhs || strcmp(lhs + 1, rhs + 1));
+ }
+
+ constexpr bool
+ strrel(const char* lhs, const char* rhs)
+ {
+ return (*rhs && (!*lhs || (*lhs < *rhs)))
+ || ((*lhs && *rhs && !(*rhs < *lhs)) && strrel(lhs + 1, rhs + 1));
+ }
+
+ constexpr bool
+ operator==(value_type const& lhs, value_type const& rhs)
+ { return (lhs.i == rhs.i) && strcmp(lhs.s, rhs.s); }
+
+ constexpr bool
+ operator!=(value_type const& lhs, value_type const& rhs)
+ { return !(lhs == rhs); }
+
+ constexpr bool
+ operator<(value_type const& lhs, value_type const& rhs)
+ { return (lhs.i < rhs.i) || (!(rhs.i < lhs.i) && strrel(lhs.s, rhs.s)); }
+
+} // namespace ns
+
+int main()
+{
+ using ns::value_type;
+ using O = std::experimental::optional<value_type>;
+
+ {
+ constexpr O o, p;
+ static_assert( o == p, "" );
+ static_assert( !(o != p), "" );
+ }
+
+ {
+ constexpr O o { value_type { 42, "forty-two" } }, p;
+ static_assert( !(o == p), "" );
+ static_assert( o != p, "" );
+ }
+
+ {
+ constexpr O o, p { value_type { 42, "forty-two" } };
+ static_assert( !(o == p), "" );
+ static_assert( o != p, "" );
+ }
+
+ {
+ constexpr O o { value_type { 11, "eleventy" } }, p { value_type { 42, "forty-two" } };
+ static_assert( !(o == p), "" );
+ static_assert( o != p, "" );
+ }
+
+ {
+ constexpr O o { value_type { 42, "forty-two" } }, p { value_type { 11, "eleventy" } };
+ static_assert( !(o == p), "" );
+ static_assert( o != p, "" );
+ }
+
+ {
+ constexpr O o { value_type { 42, "forty-two" } }, p { value_type { 42, "forty-two" } };
+ static_assert( o == p, "" );
+ static_assert( !(o != p), "" );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/2.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/2.cc
new file mode 100644
index 000000000..96da1b450
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/2.cc
@@ -0,0 +1,111 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do compile }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+namespace ns
+{
+ struct value_type
+ {
+ int i;
+ const char* s;
+ };
+
+ constexpr bool
+ strcmp(const char* lhs, const char* rhs)
+ {
+ return *lhs == *rhs && (!*lhs || strcmp(lhs + 1, rhs + 1));
+ }
+
+ constexpr bool
+ strrel(const char* lhs, const char* rhs)
+ {
+ return (*rhs && (!*lhs || (*lhs < *rhs)))
+ || ((*lhs && *rhs && !(*rhs < *lhs)) && strrel(lhs + 1, rhs + 1));
+ }
+
+ constexpr bool
+ operator==(value_type const& lhs, value_type const& rhs)
+ { return (lhs.i == rhs.i) && strcmp(lhs.s, rhs.s); }
+
+ constexpr bool
+ operator!=(value_type const& lhs, value_type const& rhs)
+ { return !(lhs == rhs); }
+
+ constexpr bool
+ operator<(value_type const& lhs, value_type const& rhs)
+ { return (lhs.i < rhs.i) || (!(rhs.i < lhs.i) && strrel(lhs.s, rhs.s)); }
+
+} // namespace ns
+
+int main()
+{
+ using ns::value_type;
+ using O = std::experimental::optional<value_type>;
+
+ {
+ constexpr O o, p;
+ static_assert( !(o < p), "" );
+ static_assert( !(o > p), "" );
+ static_assert( o <= p, "" );
+ static_assert( o >= p, "" );
+ }
+
+ {
+ constexpr O o { value_type { 42, "forty-two" } }, p;
+ static_assert( !(o < p), "" );
+ static_assert( o > p, "" );
+ static_assert( !(o <= p), "" );
+ static_assert( o >= p, "" );
+ }
+
+ {
+ constexpr O o, p { value_type { 42, "forty-two" } };
+ static_assert( o < p, "" );
+ static_assert( !(o > p), "" );
+ static_assert( o <= p, "" );
+ static_assert( !(o >= p), "" );
+ }
+
+ {
+ constexpr O o { value_type { 11, "eleventy" } }, p { value_type { 42, "forty-two" } };
+ static_assert( o < p, "" );
+ static_assert( !(o > p), "" );
+ static_assert( o <= p, "" );
+ static_assert( !(o >= p), "" );
+ }
+
+ {
+ constexpr O o { value_type { 42, "forty-two" } }, p { value_type { 11, "eleventy" } };
+ static_assert( !(o < p), "" );
+ static_assert( o > p, "" );
+ static_assert( !(o <= p), "" );
+ static_assert( o >= p, "" );
+ }
+
+ {
+ constexpr O o { value_type { 42, "forty-two" } }, p { value_type { 42, "forty-two" } };
+ static_assert( !(o < p), "" );
+ static_assert( !(o > p), "" );
+ static_assert( o <= p, "" );
+ static_assert( o >= p, "" );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/3.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/3.cc
new file mode 100644
index 000000000..b57938d52
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/3.cc
@@ -0,0 +1,89 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do compile }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+namespace ns
+{
+ struct value_type
+ {
+ int i;
+ const char* s;
+ };
+
+ constexpr bool
+ strcmp(const char* lhs, const char* rhs)
+ {
+ return *lhs == *rhs && (!*lhs || strcmp(lhs + 1, rhs + 1));
+ }
+
+ constexpr bool
+ strrel(const char* lhs, const char* rhs)
+ {
+ return (*rhs && (!*lhs || (*lhs < *rhs)))
+ || ((*lhs && *rhs && !(*rhs < *lhs)) && strrel(lhs + 1, rhs + 1));
+ }
+
+ constexpr bool
+ operator==(value_type const& lhs, value_type const& rhs)
+ { return (lhs.i == rhs.i) && strcmp(lhs.s, rhs.s); }
+
+ constexpr bool
+ operator!=(value_type const& lhs, value_type const& rhs)
+ { return !(lhs == rhs); }
+
+ constexpr bool
+ operator<(value_type const& lhs, value_type const& rhs)
+ { return (lhs.i < rhs.i) || (!(rhs.i < lhs.i) && strrel(lhs.s, rhs.s)); }
+
+} // namespace ns
+
+int main()
+{
+ using ns::value_type;
+ using O = std::experimental::optional<value_type>;
+
+ constexpr value_type reference { 42, "forty-two" };
+
+ {
+ constexpr O o;
+ static_assert( !(o == reference), "" );
+ static_assert( !(reference == o), "" );
+ static_assert( o != reference, "" );
+ static_assert( reference != o, "" );
+ }
+
+ {
+ constexpr O o { value_type { 11, "eleventy" } };
+ static_assert( !(o == reference), "" );
+ static_assert( !(reference == o), "" );
+ static_assert( o != reference, "" );
+ static_assert( reference != o, "" );
+ }
+
+ {
+ constexpr O o { value_type { 42, "forty-two" } };
+ static_assert( o == reference, "" );
+ static_assert( reference == o, "" );
+ static_assert( !(o != reference), "" );
+ static_assert( !(reference != o), "" );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/4.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/4.cc
new file mode 100644
index 000000000..67a5cd40c
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/4.cc
@@ -0,0 +1,101 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do compile }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+namespace ns
+{
+ struct value_type
+ {
+ int i;
+ const char* s;
+ };
+
+ constexpr bool
+ strcmp(const char* lhs, const char* rhs)
+ {
+ return *lhs == *rhs && (!*lhs || strcmp(lhs + 1, rhs + 1));
+ }
+
+ constexpr bool
+ strrel(const char* lhs, const char* rhs)
+ {
+ return (*rhs && (!*lhs || (*lhs < *rhs)))
+ || ((*lhs && *rhs && !(*rhs < *lhs)) && strrel(lhs + 1, rhs + 1));
+ }
+
+ constexpr bool
+ operator==(value_type const& lhs, value_type const& rhs)
+ { return (lhs.i == rhs.i) && strcmp(lhs.s, rhs.s); }
+
+ constexpr bool
+ operator!=(value_type const& lhs, value_type const& rhs)
+ { return !(lhs == rhs); }
+
+ constexpr bool
+ operator<(value_type const& lhs, value_type const& rhs)
+ { return (lhs.i < rhs.i) || (!(rhs.i < lhs.i) && strrel(lhs.s, rhs.s)); }
+
+} // namespace ns
+
+int main()
+{
+ using ns::value_type;
+ using O = std::experimental::optional<value_type>;
+
+ constexpr value_type reference { 42, "forty-two" };
+
+ {
+ constexpr O o;
+ static_assert( o < reference, "" );
+ static_assert( !(reference < o), "" );
+ static_assert( !(o > reference), "" );
+ static_assert( reference > o, "" );
+ static_assert( o <= reference, "" );
+ static_assert( !(reference <= o), "" );
+ static_assert( !(o >= reference), "" );
+ static_assert( reference >= o, "" );
+ }
+
+ {
+ constexpr O o { value_type { 11, "eleventy" } };
+ static_assert( o < reference, "" );
+ static_assert( !(reference < o), "" );
+ static_assert( !(o > reference), "" );
+ static_assert( reference > o, "" );
+ static_assert( o <= reference, "" );
+ static_assert( !(reference <= o), "" );
+ static_assert( !(o >= reference), "" );
+ static_assert( reference >= o, "" );
+ }
+
+ {
+ constexpr O o { value_type { 42, "forty-two" } };
+ static_assert( !(o < reference), "" );
+ static_assert( !(reference < o), "" );
+ static_assert( !(o > reference), "" );
+ static_assert( !(reference > o), "" );
+ static_assert( o <= reference, "" );
+ static_assert( reference <= o, "" );
+ static_assert( o >= reference, "" );
+ static_assert( reference >= o, "" );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/5.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/5.cc
new file mode 100644
index 000000000..56742d2df
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/5.cc
@@ -0,0 +1,80 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do compile }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+namespace ns
+{
+ struct value_type
+ {
+ int i;
+ const char* s;
+ };
+
+ constexpr bool
+ strcmp(const char* lhs, const char* rhs)
+ {
+ return *lhs == *rhs && (!*lhs || strcmp(lhs + 1, rhs + 1));
+ }
+
+ constexpr bool
+ strrel(const char* lhs, const char* rhs)
+ {
+ return (*rhs && (!*lhs || (*lhs < *rhs)))
+ || ((*lhs && *rhs && !(*rhs < *lhs)) && strrel(lhs + 1, rhs + 1));
+ }
+
+ constexpr bool
+ operator==(value_type const& lhs, value_type const& rhs)
+ { return (lhs.i == rhs.i) && strcmp(lhs.s, rhs.s); }
+
+ constexpr bool
+ operator!=(value_type const& lhs, value_type const& rhs)
+ { return !(lhs == rhs); }
+
+ constexpr bool
+ operator<(value_type const& lhs, value_type const& rhs)
+ { return (lhs.i < rhs.i) || (!(rhs.i < lhs.i) && strrel(lhs.s, rhs.s)); }
+
+} // namespace ns
+
+int main()
+{
+ using ns::value_type;
+ using O = std::experimental::optional<value_type>;
+ using std::experimental::nullopt;
+
+ {
+ constexpr O o;
+ static_assert( o == nullopt, "" );
+ static_assert( nullopt == o, "" );
+ static_assert( !(o != nullopt), "" );
+ static_assert( !(nullopt != o), "" );
+ }
+
+ {
+ constexpr O o { std::experimental::in_place };
+ static_assert( !(o == nullopt), "" );
+ static_assert( !(nullopt == o), "" );
+ static_assert( o != nullopt, "" );
+ static_assert( nullopt != o, "" );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/6.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/6.cc
new file mode 100644
index 000000000..b47cb61b2
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/constexpr/relops/6.cc
@@ -0,0 +1,88 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do compile }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+namespace ns
+{
+ struct value_type
+ {
+ int i;
+ const char* s;
+ };
+
+ constexpr bool
+ strcmp(const char* lhs, const char* rhs)
+ {
+ return *lhs == *rhs && (!*lhs || strcmp(lhs + 1, rhs + 1));
+ }
+
+ constexpr bool
+ strrel(const char* lhs, const char* rhs)
+ {
+ return (*rhs && (!*lhs || (*lhs < *rhs)))
+ || ((*lhs && *rhs && !(*rhs < *lhs)) && strrel(lhs + 1, rhs + 1));
+ }
+
+ constexpr bool
+ operator==(value_type const& lhs, value_type const& rhs)
+ { return (lhs.i == rhs.i) && strcmp(lhs.s, rhs.s); }
+
+ constexpr bool
+ operator!=(value_type const& lhs, value_type const& rhs)
+ { return !(lhs == rhs); }
+
+ constexpr bool
+ operator<(value_type const& lhs, value_type const& rhs)
+ { return (lhs.i < rhs.i) || (!(rhs.i < lhs.i) && strrel(lhs.s, rhs.s)); }
+
+} // namespace ns
+
+int main()
+{
+ using ns::value_type;
+ using O = std::experimental::optional<value_type>;
+ using std::experimental::nullopt;
+
+ {
+ constexpr O o;
+ static_assert( !(o < nullopt), "" );
+ static_assert( !(nullopt < o), "" );
+ static_assert( !(o > nullopt), "" );
+ static_assert( !(nullopt > o), "" );
+ static_assert( o <= nullopt, "" );
+ static_assert( nullopt <= o, "" );
+ static_assert( o >= nullopt, "" );
+ static_assert( nullopt >= o, "" );
+ }
+
+ {
+ constexpr O o { std::experimental::in_place };
+ static_assert( !(o < nullopt), "" );
+ static_assert( nullopt < o, "" );
+ static_assert( o > nullopt, "" );
+ static_assert( !(nullopt > o), "" );
+ static_assert( !(o <= nullopt), "" );
+ static_assert( nullopt <= o, "" );
+ static_assert( o >= nullopt, "" );
+ static_assert( !(nullopt >= o), "" );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/in_place.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/in_place.cc
new file mode 100644
index 000000000..66525b27a
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/in_place.cc
@@ -0,0 +1,66 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+#include <vector>
+
+int main()
+{
+ // [20.5.5] In-place construction
+ static_assert( std::is_same<decltype(std::experimental::in_place), const std::experimental::in_place_t>(), "" );
+ static_assert( std::is_empty<std::experimental::in_place_t>(), "" );
+
+ {
+ std::experimental::optional<int> o { std::experimental::in_place };
+ VERIFY( o );
+ VERIFY( *o == int() );
+
+ static_assert( !std::is_convertible<std::experimental::in_place_t, std::experimental::optional<int>>(), "" );
+ }
+
+ {
+ std::experimental::optional<int> o { std::experimental::in_place, 42 };
+ VERIFY( o );
+ VERIFY( *o == 42 );
+ }
+
+ {
+ std::experimental::optional<std::vector<int>> o { std::experimental::in_place, 18, 4 };
+ VERIFY( o );
+ VERIFY( o->size() == 18 );
+ VERIFY( (*o)[17] == 4 );
+ }
+
+ {
+ std::experimental::optional<std::vector<int>> o { std::experimental::in_place, { 18, 4 } };
+ VERIFY( o );
+ VERIFY( o->size() == 2 );
+ VERIFY( (*o)[0] == 18 );
+ }
+
+ {
+ std::experimental::optional<std::vector<int>> o { std::experimental::in_place, { 18, 4 }, std::allocator<int> {} };
+ VERIFY( o );
+ VERIFY( o->size() == 2 );
+ VERIFY( (*o)[0] == 18 );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/make_optional.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/make_optional.cc
new file mode 100644
index 000000000..99122c018
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/make_optional.cc
@@ -0,0 +1,31 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ const int i = 42;
+ auto o = std::experimental::make_optional(i);
+ static_assert( std::is_same<decltype(o), std::experimental::optional<int>>(), "" );
+ VERIFY( o && *o == 42 );
+ VERIFY( &*o != &i );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/nullopt.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/nullopt.cc
new file mode 100644
index 000000000..560579791
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/nullopt.cc
@@ -0,0 +1,46 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ // [20.5.6] Disengaged state indicator
+ static_assert( std::is_same<decltype(std::experimental::nullopt), const std::experimental::nullopt_t>(), "" );
+ static_assert( std::is_empty<std::experimental::nullopt_t>(), "" );
+ static_assert( std::is_literal_type<std::experimental::nullopt_t>(), "" );
+ static_assert( !std::is_default_constructible<std::experimental::nullopt_t>(), "" );
+
+ {
+ std::experimental::optional<int> o = std::experimental::nullopt;
+ VERIFY( !o );
+ }
+
+ {
+ std::experimental::optional<int> o = { std::experimental::nullopt };
+ VERIFY( !o );
+ }
+
+ {
+ std::experimental::optional<int> o { std::experimental::nullopt };
+ VERIFY( !o );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/1.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/1.cc
new file mode 100644
index 000000000..0316df6ed
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/1.cc
@@ -0,0 +1,33 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct value_type
+{
+ int i;
+};
+
+int main()
+{
+ std::experimental::optional<value_type> o { value_type { 51 } };
+ VERIFY( (*o).i == 51 );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/2.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/2.cc
new file mode 100644
index 000000000..924ed095d
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/2.cc
@@ -0,0 +1,35 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct value_type
+{
+ int i;
+};
+
+int main()
+{
+ std::experimental::optional<value_type> o { value_type { 51 } };
+ VERIFY( o->i == 51 );
+ VERIFY( o->i == (*o).i );
+ VERIFY( &o->i == &(*o).i );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/3.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/3.cc
new file mode 100644
index 000000000..bdaf6cbba
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/3.cc
@@ -0,0 +1,58 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct value_type
+{
+ int i;
+};
+
+int main()
+{
+ {
+ std::experimental::optional<value_type> o { value_type { 51 } };
+ VERIFY( o.value().i == 51 );
+ VERIFY( o.value().i == (*o).i );
+ VERIFY( &o.value().i == &(*o).i );
+ }
+
+ {
+ enum outcome_type { nothrow, caught, bad_catch };
+
+ outcome_type outcome {};
+ std::experimental::optional<value_type> o = std::experimental::nullopt;
+ bool called = false;
+ auto const eat = [&called](int) { called = true; };
+
+ try
+ {
+ eat(o.value().i);
+ }
+ catch(std::experimental::bad_optional_access const&)
+ { outcome = caught; }
+ catch(...)
+ { outcome = bad_catch; }
+
+ VERIFY( outcome == caught );
+ VERIFY( !called );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/4.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/4.cc
new file mode 100644
index 000000000..a738f121c
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/4.cc
@@ -0,0 +1,35 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct value_type
+{
+ int i;
+};
+
+int main()
+{
+ std::experimental::optional<value_type> o { value_type { 51 } };
+ value_type fallback { 3 };
+ VERIFY( o.value_or(fallback).i == 51 );
+ VERIFY( o.value_or(fallback).i == (*o).i );
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/5.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/5.cc
new file mode 100644
index 000000000..c6a602282
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/observers/5.cc
@@ -0,0 +1,40 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct value_type
+{
+ int i;
+};
+
+int main()
+{
+ {
+ std::experimental::optional<value_type> o = std::experimental::nullopt;
+ VERIFY( !o );
+ }
+
+ {
+ std::experimental::optional<value_type> o { value_type { 51 } };
+ VERIFY( o );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/1.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/1.cc
new file mode 100644
index 000000000..f1408805a
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/1.cc
@@ -0,0 +1,89 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+#include <tuple>
+#include <string>
+
+namespace ns
+{
+ struct value_type
+ {
+ int i;
+ std::string s;
+ };
+
+ bool
+ operator==(value_type const& lhs, value_type const& rhs)
+ { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); }
+
+ bool
+ operator!=(value_type const& lhs, value_type const& rhs)
+ { return !(lhs == rhs); }
+
+ bool
+ operator<(value_type const& lhs, value_type const& rhs)
+ { return std::tie(lhs.i, lhs.s) < std::tie(rhs.i, rhs.s); }
+
+} // namespace ns
+
+int main()
+{
+ using ns::value_type;
+ using O = std::experimental::optional<value_type>;
+
+ {
+ O o, p;
+ VERIFY( o == p );
+ VERIFY( !(o != p) );
+ }
+
+ {
+ O o { value_type { 42, "forty-two" } }, p;
+ VERIFY( !(o == p) );
+ VERIFY( o != p );
+ }
+
+ {
+ O o, p { value_type { 42, "forty-two" } };
+ VERIFY( !(o == p) );
+ VERIFY( o != p );
+ }
+
+ {
+ O o { value_type { 11, "eleventy" } }, p { value_type { 42, "forty-two" } };
+ VERIFY( !(o == p) );
+ VERIFY( o != p );
+ }
+
+ {
+ O o { value_type { 42, "forty-two" } }, p { value_type { 11, "eleventy" } };
+ VERIFY( !(o == p) );
+ VERIFY( o != p );
+ }
+
+ {
+ O o { value_type { 42, "forty-two" } }, p { value_type { 42, "forty-two" } };
+ VERIFY( o == p );
+ VERIFY( !(o != p) );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/2.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/2.cc
new file mode 100644
index 000000000..c7fc848de
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/2.cc
@@ -0,0 +1,101 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+#include <tuple>
+#include <string>
+
+namespace ns
+{
+ struct value_type
+ {
+ int i;
+ std::string s;
+ };
+
+ bool
+ operator==(value_type const& lhs, value_type const& rhs)
+ { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); }
+
+ bool
+ operator!=(value_type const& lhs, value_type const& rhs)
+ { return !(lhs == rhs); }
+
+ bool
+ operator<(value_type const& lhs, value_type const& rhs)
+ { return std::tie(lhs.i, lhs.s) < std::tie(rhs.i, rhs.s); }
+
+} // namespace ns
+
+int main()
+{
+ using ns::value_type;
+ using O = std::experimental::optional<value_type>;
+
+ {
+ O o, p;
+ VERIFY( !(o < p) );
+ VERIFY( !(o > p) );
+ VERIFY( o <= p );
+ VERIFY( o >= p );
+ }
+
+ {
+ O o { value_type { 42, "forty-two" } }, p;
+ VERIFY( !(o < p) );
+ VERIFY( o > p );
+ VERIFY( !(o <= p) );
+ VERIFY( o >= p );
+ }
+
+ {
+ O o, p { value_type { 42, "forty-two" } };
+ VERIFY( o < p );
+ VERIFY( !(o > p) );
+ VERIFY( o <= p );
+ VERIFY( !(o >= p) );
+ }
+
+ {
+ O o { value_type { 11, "eleventy" } }, p { value_type { 42, "forty-two" } };
+ VERIFY( o < p );
+ VERIFY( !(o > p) );
+ VERIFY( o <= p );
+ VERIFY( !(o >= p) );
+ }
+
+ {
+ O o { value_type { 42, "forty-two" } }, p { value_type { 11, "eleventy" } };
+ VERIFY( !(o < p) );
+ VERIFY( o > p );
+ VERIFY( !(o <= p) );
+ VERIFY( o >= p );
+ }
+
+ {
+ O o { value_type { 42, "forty-two" } }, p { value_type { 42, "forty-two" } };
+ VERIFY( !(o < p) );
+ VERIFY( !(o > p) );
+ VERIFY( o <= p );
+ VERIFY( o >= p );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/3.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/3.cc
new file mode 100644
index 000000000..9729000d5
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/3.cc
@@ -0,0 +1,79 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+#include <tuple>
+#include <string>
+
+namespace ns
+{
+ struct value_type
+ {
+ int i;
+ std::string s;
+ };
+
+ bool
+ operator==(value_type const& lhs, value_type const& rhs)
+ { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); }
+
+ bool
+ operator!=(value_type const& lhs, value_type const& rhs)
+ { return !(lhs == rhs); }
+
+ bool
+ operator<(value_type const& lhs, value_type const& rhs)
+ { return std::tie(lhs.i, lhs.s) < std::tie(rhs.i, rhs.s); }
+
+} // namespace ns
+
+int main()
+{
+ using ns::value_type;
+ using O = std::experimental::optional<value_type>;
+
+ value_type const reference { 42, "forty-two" };
+
+ {
+ O o;
+ VERIFY( !(o == reference) );
+ VERIFY( !(reference == o) );
+ VERIFY( o != reference );
+ VERIFY( reference != o );
+ }
+
+ {
+ O o { value_type { 11, "eleventy" } };
+ VERIFY( !(o == reference) );
+ VERIFY( !(reference == o) );
+ VERIFY( o != reference );
+ VERIFY( reference != o );
+ }
+
+ {
+ O o { value_type { 42, "forty-two" } };
+ VERIFY( o == reference );
+ VERIFY( reference == o );
+ VERIFY( !(o != reference) );
+ VERIFY( !(reference != o) );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/4.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/4.cc
new file mode 100644
index 000000000..45378f688
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/4.cc
@@ -0,0 +1,91 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+#include <tuple>
+#include <string>
+
+namespace ns
+{
+ struct value_type
+ {
+ int i;
+ std::string s;
+ };
+
+ bool
+ operator==(value_type const& lhs, value_type const& rhs)
+ { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); }
+
+ bool
+ operator!=(value_type const& lhs, value_type const& rhs)
+ { return !(lhs == rhs); }
+
+ bool
+ operator<(value_type const& lhs, value_type const& rhs)
+ { return std::tie(lhs.i, lhs.s) < std::tie(rhs.i, rhs.s); }
+
+} // namespace ns
+
+int main()
+{
+ using ns::value_type;
+ using O = std::experimental::optional<value_type>;
+
+ value_type const reference { 42, "forty-two" };
+
+ {
+ O o;
+ VERIFY( o < reference );
+ VERIFY( !(reference < o) );
+ VERIFY( !(o > reference) );
+ VERIFY( reference > o );
+ VERIFY( o <= reference );
+ VERIFY( !(reference <= o) );
+ VERIFY( !(o >= reference) );
+ VERIFY( reference >= o );
+ }
+
+ {
+ O o { value_type { 11, "eleventy" } };
+ VERIFY( o < reference );
+ VERIFY( !(reference < o) );
+ VERIFY( !(o > reference) );
+ VERIFY( reference > o );
+ VERIFY( o <= reference );
+ VERIFY( !(reference <= o) );
+ VERIFY( !(o >= reference) );
+ VERIFY( reference >= o );
+ }
+
+ {
+ O o { value_type { 42, "forty-two" } };
+ VERIFY( !(o < reference) );
+ VERIFY( !(reference < o) );
+ VERIFY( !(o > reference) );
+ VERIFY( !(reference > o) );
+ VERIFY( o <= reference );
+ VERIFY( reference <= o );
+ VERIFY( o >= reference );
+ VERIFY( reference >= o );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/5.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/5.cc
new file mode 100644
index 000000000..008409ef4
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/5.cc
@@ -0,0 +1,70 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+#include <tuple>
+#include <string>
+
+namespace ns
+{
+ struct value_type
+ {
+ int i;
+ std::string s;
+ };
+
+ bool
+ operator==(value_type const& lhs, value_type const& rhs)
+ { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); }
+
+ bool
+ operator!=(value_type const& lhs, value_type const& rhs)
+ { return !(lhs == rhs); }
+
+ bool
+ operator<(value_type const& lhs, value_type const& rhs)
+ { return std::tie(lhs.i, lhs.s) < std::tie(rhs.i, rhs.s); }
+
+} // namespace ns
+
+int main()
+{
+ using ns::value_type;
+ using O = std::experimental::optional<value_type>;
+ using std::experimental::nullopt;
+
+ {
+ O o;
+ VERIFY( o == nullopt );
+ VERIFY( nullopt == o );
+ VERIFY( !(o != nullopt) );
+ VERIFY( !(nullopt != o) );
+ }
+
+ {
+ O o { std::experimental::in_place };
+ VERIFY( !(o == nullopt) );
+ VERIFY( !(nullopt == o) );
+ VERIFY( o != nullopt );
+ VERIFY( nullopt != o );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/6.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/6.cc
new file mode 100644
index 000000000..b17914062
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/relops/6.cc
@@ -0,0 +1,78 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+#include <tuple>
+#include <string>
+
+namespace ns
+{
+ struct value_type
+ {
+ int i;
+ std::string s;
+ };
+
+ bool
+ operator==(value_type const& lhs, value_type const& rhs)
+ { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); }
+
+ bool
+ operator!=(value_type const& lhs, value_type const& rhs)
+ { return !(lhs == rhs); }
+
+ bool
+ operator<(value_type const& lhs, value_type const& rhs)
+ { return std::tie(lhs.i, lhs.s) < std::tie(rhs.i, rhs.s); }
+
+} // namespace ns
+
+int main()
+{
+ using ns::value_type;
+ using O = std::experimental::optional<value_type>;
+ using std::experimental::nullopt;
+
+ {
+ O o;
+ VERIFY( !(o < nullopt) );
+ VERIFY( !(nullopt < o) );
+ VERIFY( !(o > nullopt) );
+ VERIFY( !(nullopt > o) );
+ VERIFY( o <= nullopt );
+ VERIFY( nullopt <= o );
+ VERIFY( o >= nullopt );
+ VERIFY( nullopt >= o );
+ }
+
+ {
+ O o { std::experimental::in_place };
+ VERIFY( !(o < nullopt) );
+ VERIFY( nullopt < o );
+ VERIFY( o > nullopt );
+ VERIFY( !(nullopt > o) );
+ VERIFY( !(o <= nullopt) );
+ VERIFY( nullopt <= o );
+ VERIFY( o >= nullopt );
+ VERIFY( !(nullopt >= o) );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/requirements.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/requirements.cc
new file mode 100644
index 000000000..4b0535b47
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/requirements.cc
@@ -0,0 +1,256 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+#include <tuple>
+
+struct trivially_destructible
+{
+ trivially_destructible() = delete;
+ trivially_destructible(trivially_destructible const&) = delete;
+ trivially_destructible& operator=(trivially_destructible const&) = delete;
+ trivially_destructible(trivially_destructible&&) = delete;
+ trivially_destructible& operator=(trivially_destructible&&) = delete;
+ ~trivially_destructible() noexcept = default;
+};
+
+static_assert( std::is_trivially_destructible<trivially_destructible>(), "" );
+
+struct no_default_constructor
+{
+ no_default_constructor() = delete;
+};
+
+struct no_copy_constructor
+{
+ no_copy_constructor() = default;
+ no_copy_constructor(no_copy_constructor const&) = delete;
+ no_copy_constructor& operator=(no_copy_constructor const&) = default;
+ no_copy_constructor(no_copy_constructor&&) = default;
+ no_copy_constructor& operator=(no_copy_constructor&&) = default;
+};
+
+struct no_copy_assignment
+{
+ no_copy_assignment() = default;
+ no_copy_assignment(no_copy_assignment const&) = default;
+ no_copy_assignment(no_copy_assignment&&) = default;
+ no_copy_assignment& operator=(no_copy_assignment&&) = default;
+};
+
+struct no_move_constructor
+{
+ no_move_constructor() = default;
+ no_move_constructor(no_move_constructor const&) = default;
+ no_move_constructor& operator=(no_move_constructor const&) = default;
+ no_move_constructor(no_move_constructor&&) = delete;
+ no_move_constructor& operator=(no_move_constructor&&) = default;
+};
+
+struct no_move_assignment
+{
+ no_move_assignment() = default;
+ no_move_assignment(no_move_assignment const&) = default;
+ no_move_assignment& operator=(no_move_assignment const&) = default;
+ no_move_assignment(no_move_assignment&&) = default;
+ no_move_assignment& operator=(no_move_assignment&&) = delete;
+};
+
+struct no_copy : no_copy_constructor, no_copy_assignment { };
+struct no_move : no_move_constructor, no_move_assignment { };
+
+// Laxest possible model of a value type for optional
+struct only_destructible
+{
+ only_destructible(only_destructible&&) = delete;
+};
+
+int main()
+{
+ {
+ static_assert( std::is_trivially_destructible<std::experimental::optional<trivially_destructible>>(), "" );
+ }
+
+ {
+ using T = no_default_constructor;
+ using O = std::experimental::optional<T>;
+ static_assert( std::is_same<O::value_type, T>(), "" );
+ static_assert( std::is_default_constructible<O>(), "" );
+ { O o; }
+ static_assert( std::is_copy_constructible<O>(), "" );
+ { O o; auto copy = o; }
+ static_assert( std::is_copy_assignable<O>(), "" );
+ { O o, p; p = o; }
+ static_assert( std::is_move_constructible<O>(), "" );
+ { O o; auto moved_to = std::move(o); }
+ static_assert( std::is_move_assignable<O>(), "" );
+ { O o, p; p = std::move(o); }
+ }
+
+ {
+ using T = no_copy_constructor;
+ using O = std::experimental::optional<T>;
+ static_assert( std::is_same<O::value_type, T>(), "" );
+ static_assert( std::is_default_constructible<O>(), "" );
+ { O o; }
+ static_assert( !std::is_copy_constructible<O>(), "" );
+ static_assert( !std::is_copy_assignable<O>(), "" );
+ static_assert( std::is_move_constructible<O>(), "" );
+ { O o; auto moved_to = std::move(o); }
+ static_assert( std::is_move_assignable<O>(), "" );
+ { O o, p; p = std::move(o); }
+ }
+
+ {
+ using T = no_copy_assignment;
+ using O = std::experimental::optional<T>;
+ static_assert( std::is_default_constructible<O>(), "" );
+ { O o; }
+ static_assert( std::is_copy_constructible<O>(), "" );
+ { O o; auto copy = o; }
+ static_assert( !std::is_copy_assignable<O>(), "" );
+ static_assert( std::is_move_constructible<O>(), "" );
+ { O o; auto moved_to = std::move(o); }
+ static_assert( std::is_move_assignable<O>(), "" );
+ { O o, p; p = std::move(o); }
+ }
+
+ {
+ using T = no_copy;
+ using O = std::experimental::optional<T>;
+ static_assert( std::is_same<O::value_type, T>(), "" );
+ static_assert( std::is_default_constructible<O>(), "" );
+ { O o; }
+ static_assert( !std::is_copy_constructible<O>(), "" );
+ static_assert( !std::is_copy_assignable<O>(), "" );
+ static_assert( std::is_move_constructible<O>(), "" );
+ { O o; auto moved_to = std::move(o); }
+ static_assert( std::is_move_assignable<O>(), "" );
+ { O o, p; p = std::move(o); }
+ }
+
+ {
+ using T = no_move_constructor;
+ using O = std::experimental::optional<T>;
+ static_assert( std::is_same<O::value_type, T>(), "" );
+ static_assert( std::is_default_constructible<O>(), "" );
+ { O o; }
+ static_assert( std::is_copy_constructible<O>(), "" );
+ { O o; auto copy = o; }
+ static_assert( std::is_copy_assignable<O>(), "" );
+ /*
+ * T should be move constructible due to [12.8/11], which is a new rule in C++1y
+ * not yet implemented by GCC. Because there is already a special exception in C++11
+ * for the generation of the special members that GCC implements (at least some of the
+ * time), this does not affect the std::experimental::optional implementation however. So the assertion
+ * for T should be changed (or removed altogether) when the time comes, but the rest
+ * should however remain correct and unchanged.
+ */
+ static_assert( !std::is_move_constructible<T>(), "" );
+ static_assert( std::is_move_constructible<O>(), "" );
+ { O o; auto moved_to = std::move(o); }
+ static_assert( std::is_move_assignable<O>(), "" );
+ { O o, p; p = std::move(o); }
+ }
+
+ {
+ using T = no_move_assignment;
+ using O = std::experimental::optional<T>;
+ static_assert( std::is_same<O::value_type, T>(), "" );
+ static_assert( std::is_default_constructible<O>(), "" );
+ { O o; }
+ static_assert( std::is_copy_constructible<O>(), "" );
+ { O o; auto copy = o; }
+ static_assert( std::is_copy_assignable<O>(), "" );
+ { O o, p; p = o; }
+ static_assert( std::is_move_constructible<O>(), "" );
+ { O o; auto moved_to = std::move(o); }
+ /*
+ * Paragraph 23 of same leads to a similar situation but with respect to move
+ * assignment.
+ */
+ static_assert( !std::is_move_assignable<T>(), "" );
+ static_assert( std::is_move_assignable<O>(), "" );
+ { O o, p; p = std::move(o); }
+ }
+
+ {
+ using T = no_move;
+ using O = std::experimental::optional<T>;
+ static_assert( std::is_same<O::value_type, T>(), "" );
+ static_assert( std::is_default_constructible<O>(), "" );
+ { O o; }
+ static_assert( std::is_copy_constructible<O>(), "" );
+ { O o; auto copy = o; }
+ static_assert( std::is_copy_assignable<O>(), "" );
+ { O o, p; p = o; }
+ static_assert( std::is_move_constructible<O>(), "" );
+ { O o; auto moved_to = std::move(o); }
+ static_assert( std::is_move_assignable<O>(), "" );
+ { O o, p; p = std::move(o); }
+ }
+
+ {
+ using T = only_destructible;
+ using O = std::experimental::optional<T>;
+ static_assert( std::is_same<O::value_type, T>(), "" );
+ static_assert( std::is_default_constructible<O>(), "" );
+ { O o; }
+ static_assert( !std::is_copy_constructible<O>(), "" );
+ static_assert( !std::is_copy_assignable<O>(), "" );
+ static_assert( !std::is_move_constructible<O>(), "" );
+ static_assert( !std::is_move_assignable<O>(), "" );
+ }
+
+ {
+ /*
+ * Should not complain about 'invalid' specializations as long as
+ * they're not instantiated.
+ */
+ using A = std::experimental::optional<int&>;
+ using B = std::experimental::optional<int&&>;
+ using C1 = std::experimental::optional<std::experimental::in_place_t>;
+ using C2 = std::experimental::optional<std::experimental::in_place_t const>;
+ using C3 = std::experimental::optional<std::experimental::in_place_t volatile>;
+ using C4 = std::experimental::optional<std::experimental::in_place_t const volatile>;
+ using D1 = std::experimental::optional<std::experimental::nullopt_t>;
+ using D2 = std::experimental::optional<std::experimental::nullopt_t const>;
+ using D3 = std::experimental::optional<std::experimental::nullopt_t volatile>;
+ using D4 = std::experimental::optional<std::experimental::nullopt_t const volatile>;
+
+ using X = std::tuple<A, B, C1, C2, C3, C4, D1, D2, D3, D4>;
+ }
+
+ {
+ std::experimental::optional<const int> o { 42 };
+ static_assert( std::is_same<decltype(o)::value_type, const int>(), "" );
+ VERIFY( o );
+ VERIFY( *o == 42 );
+ }
+
+ {
+ constexpr std::experimental::optional<const int> o { 33 };
+ static_assert( std::is_same<decltype(o)::value_type, const int>(), "" );
+ static_assert( o, "" );
+ static_assert( *o == 33, "" );
+ }
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/swap/1.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/swap/1.cc
new file mode 100644
index 000000000..db754ce3e
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/optional/swap/1.cc
@@ -0,0 +1,95 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/optional>
+#include <testsuite_hooks.h>
+
+struct exception {};
+
+int counter = 0;
+
+struct mixin_counter
+{
+ mixin_counter() { ++counter; }
+ mixin_counter(mixin_counter const&) { ++counter; }
+ ~mixin_counter() { --counter; }
+};
+
+namespace ns
+{
+
+struct value_type : private mixin_counter
+{
+ explicit value_type(int state) : state(state) { }
+ int state;
+};
+
+int swaps = 0;
+
+void
+swap(value_type& lhs, value_type& rhs)
+{
+ ++swaps;
+ using std::swap;
+ swap(lhs.state, rhs.state);
+}
+
+} // namespace ns
+
+int main()
+{
+ using O = std::experimental::optional<ns::value_type>;
+
+ VERIFY( ns::swaps == 0 );
+
+ {
+ O o, p;
+ swap(o, p);
+ VERIFY( !o );
+ VERIFY( !p );
+ }
+
+ {
+ O o { std::experimental::in_place, 45 }, p;
+ swap(o, p);
+ VERIFY( !o );
+ VERIFY( p && p->state == 45 );
+ }
+
+ {
+ O o, p { std::experimental::in_place, 45 };
+ swap(o, p);
+ VERIFY( o && o->state == 45 );
+ VERIFY( !p );
+ }
+
+ {
+ O o { std::experimental::in_place, 167 }, p { std::experimental::in_place, 999 };
+ VERIFY( ns::swaps == 0 );
+
+ swap(o, p);
+
+ VERIFY( o && o->state == 999 );
+ VERIFY( p && p->state == 167 );
+ VERIFY( ns::swaps == 1 );
+ }
+
+ VERIFY( counter == 0 );
+}