This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix specializations of std::uses_allocator in <queue> and <stack>
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Mon, 22 Sep 2014 17:01:50 +0100
- Subject: [patch] Fix specializations of std::uses_allocator in <queue> and <stack>
- Authentication-results: sourceware.org; auth=none
Include missing header, and add tests.
Tested x86_64-linux, committed to trunk.
commit a0ffb1d4d0bf78be525c7546665ef7002b66b13e
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Mon Sep 22 16:42:51 2014 +0100
Include <bits/uses_allocator.h> in <stack> and <queue>.
* include/bits/stl_queue.h: Include missing header.
* include/bits/stl_stack.h: Likewise.
* testsuite/23_containers/priority_queue/requirements/
uses_allocator.cc: New.
* testsuite/23_containers/queue/requirements/uses_allocator.cc: New.
* testsuite/23_containers/stack/requirements/uses_allocator.cc: New.
diff --git a/libstdc++-v3/include/bits/stl_queue.h b/libstdc++-v3/include/bits/stl_queue.h
index b516664..32124e3 100644
--- a/libstdc++-v3/include/bits/stl_queue.h
+++ b/libstdc++-v3/include/bits/stl_queue.h
@@ -58,6 +58,9 @@
#include <bits/concept_check.h>
#include <debug/debug.h>
+#if __cplusplus >= 201103L
+# include <bits/uses_allocator.h>
+#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
diff --git a/libstdc++-v3/include/bits/stl_stack.h b/libstdc++-v3/include/bits/stl_stack.h
index ee187da..f4bb72c 100644
--- a/libstdc++-v3/include/bits/stl_stack.h
+++ b/libstdc++-v3/include/bits/stl_stack.h
@@ -58,6 +58,9 @@
#include <bits/concept_check.h>
#include <debug/debug.h>
+#if __cplusplus >= 201103L
+# include <bits/uses_allocator.h>
+#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
diff --git a/libstdc++-v3/testsuite/23_containers/priority_queue/requirements/uses_allocator.cc b/libstdc++-v3/testsuite/23_containers/priority_queue/requirements/uses_allocator.cc
new file mode 100644
index 0000000..efe73ae
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/priority_queue/requirements/uses_allocator.cc
@@ -0,0 +1,29 @@
+// 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/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+#include <queue>
+
+template<typename A>
+ using uses_allocator = std::uses_allocator<std::priority_queue<int>, A>;
+
+static_assert( uses_allocator<std::allocator<int>>::value, "valid allocator" );
+
+struct X { };
+static_assert( !uses_allocator<X>::value, "invalid allocator" );
diff --git a/libstdc++-v3/testsuite/23_containers/queue/requirements/uses_allocator.cc b/libstdc++-v3/testsuite/23_containers/queue/requirements/uses_allocator.cc
new file mode 100644
index 0000000..42106ca
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/queue/requirements/uses_allocator.cc
@@ -0,0 +1,29 @@
+// 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/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+#include <queue>
+
+template<typename A>
+ using uses_allocator = std::uses_allocator<std::queue<int>, A>;
+
+static_assert( uses_allocator<std::allocator<int>>::value, "valid allocator" );
+
+struct X { };
+static_assert( !uses_allocator<X>::value, "invalid allocator" );
diff --git a/libstdc++-v3/testsuite/23_containers/stack/requirements/uses_allocator.cc b/libstdc++-v3/testsuite/23_containers/stack/requirements/uses_allocator.cc
new file mode 100644
index 0000000..3663d63
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/stack/requirements/uses_allocator.cc
@@ -0,0 +1,29 @@
+// 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/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+#include <stack>
+
+template<typename A>
+ using uses_allocator = std::uses_allocator<std::stack<int>, A>;
+
+static_assert( uses_allocator<std::allocator<int>>::value, "valid allocator" );
+
+struct X { };
+static_assert( !uses_allocator<X>::value, "invalid allocator" );