summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2014-07-10 18:08:35 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2014-07-10 18:08:35 +0000
commit35c730f29bd5690c463497576b4d0e77eac01be8 (patch)
treea5f3ef6ecf2264b35f8ef426c1265d573200c8de /libstdc++-v3/testsuite
parenta00ef6ba893e9b01bbcad806197ebc7ca4e461e5 (diff)
downloadgcc-35c730f29bd5690c463497576b4d0e77eac01be8.tar.gz
* include/experimental/any (any::_Manager_alloc::_Data): Reorder
tuple members to simplify pretty printing. (any::_Manager_alloc::_Data::_M_construct): Fix uses-allocator construction. * testsuite/experimental/any/cons/4.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@212435 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/experimental/any/cons/4.cc73
1 files changed, 73 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/experimental/any/cons/4.cc b/libstdc++-v3/testsuite/experimental/any/cons/4.cc
new file mode 100644
index 00000000000..6e5e01972e3
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/any/cons/4.cc
@@ -0,0 +1,73 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do run }
+
+// Copyright (C) 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/any>
+#include <memory>
+#include <testsuite_hooks.h>
+
+using std::experimental::any;
+
+struct NotSmall
+{
+ char c[64]; // prevent small-object optimization
+};
+
+struct T1
+{
+ using allocator_type = std::allocator<char>;
+
+ T1() = default;
+ T1(const T1&) : used_alloc(false) { }
+ T1(const T1&, const allocator_type&) : used_alloc(true) { }
+
+ bool used_alloc;
+
+ NotSmall x;
+};
+
+struct T2
+{
+ using allocator_type = std::allocator<char>;
+
+ T2() = default;
+ T2(const T2&) : used_alloc(false) { }
+ T2(std::allocator_arg_t, const allocator_type&, const T2&) : used_alloc(true)
+ { }
+
+ bool used_alloc;
+
+ NotSmall x;
+};
+
+bool test [[gnu::unused]] = true;
+
+void test01()
+{
+ any x1(std::allocator_arg, std::allocator<char>{}, T1{});
+ VERIFY( std::experimental::any_cast<T1&>(x1).used_alloc );
+
+ any x2(std::allocator_arg, std::allocator<char>{}, T2{});
+ VERIFY( std::experimental::any_cast<T2&>(x2).used_alloc );
+}
+
+int main()
+{
+ test01();
+}