aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/optional/test_type_traits.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2016-07-13 11:19:24 +0200
committerEike Ziller <eike.ziller@qt.io>2017-06-16 12:19:27 +0000
commit93f4fb771fbfcb8499601b497a4b2b436d872c1d (patch)
tree2778fa04bc9a160ab4a639910627065cd408f9ef /src/libs/3rdparty/optional/test_type_traits.cpp
parent42580c7d0ca703f216bcb19e12259b1022d8b423 (diff)
Add std::experimental::optional as Utils::optional
Uses the reference implementation of the proposal, which later can be replaced by the std lib implementation depending on compiler and used C++ version. Change-Id: I23f2f8077f4cb26c3d9a403b1ce438b6cdb163f2 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/libs/3rdparty/optional/test_type_traits.cpp')
-rw-r--r--src/libs/3rdparty/optional/test_type_traits.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/libs/3rdparty/optional/test_type_traits.cpp b/src/libs/3rdparty/optional/test_type_traits.cpp
new file mode 100644
index 0000000000..8ec82b7087
--- /dev/null
+++ b/src/libs/3rdparty/optional/test_type_traits.cpp
@@ -0,0 +1,66 @@
+// Copyright (C) 2011 - 2012 Andrzej Krzemienski.
+//
+// Use, modification, and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#if (defined __clang__)
+ namespace std { class type_info; }
+#endif
+
+# include "optional.hpp"
+
+namespace std { namespace experimental {
+
+struct Val
+{
+ Val(){}
+ Val( Val const & ){}
+ Val( Val && ) noexcept {}
+
+ Val & operator=( Val const & ) = delete;
+ Val & operator=( Val && ) noexcept = delete;
+};
+
+struct Safe
+{
+ Safe(){}
+ Safe( Safe const & ){}
+ Safe( Safe && ) noexcept {}
+
+ Safe & operator=( Safe const & ){ return *this; }
+ Safe & operator=( Safe && ) noexcept { return *this; }
+};
+
+struct Unsafe
+{
+ Unsafe(){}
+ Unsafe( Unsafe const & ){}
+ Unsafe( Unsafe && ){}
+
+ Unsafe & operator=( Unsafe const & ){ return *this; }
+ Unsafe & operator=( Unsafe && ) { return *this; }
+};
+
+struct VoidNothrowBoth
+{
+ VoidNothrowBoth(VoidNothrowBoth&&) noexcept(true) {};
+ void operator=(VoidNothrowBoth&&) noexcept(true) {}; // note void return type
+};
+
+
+static_assert(is_nothrow_move_constructible<Safe>::value, "WTF!");
+static_assert(!is_nothrow_move_constructible<Unsafe>::value, "WTF!");
+
+static_assert(is_assignable<Safe&, Safe&&>::value, "WTF!");
+static_assert(!is_assignable<Val&, Val&&>::value, "WTF!");
+
+static_assert(is_nothrow_move_assignable<Safe>::value, "WTF!");
+static_assert(!is_nothrow_move_assignable<Unsafe>::value, "WTF!");
+
+static_assert(is_nothrow_move_constructible<VoidNothrowBoth>::value, "WTF!");
+static_assert(is_nothrow_move_assignable<VoidNothrowBoth>::value, "WTF!");
+
+}} // namespace std::experimental
+
+int main() { }