@@ -123,6 +123,40 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Inherit everything else.
};
+ /// Partial specialization for const types
+ template<typename _Tp>
+ class allocator<const _Tp> : public allocator<_Tp>
+ {
+#if __cplusplus >= 201103L
+ public:
+ allocator()
+ {
+ static_assert( !is_const<const _Tp>::value,
+ "allocator's value_type must be non-const" );
+ }
+#else
+ private:
+ allocator();
+#endif
+ };
+
+ /// Partial specialization for reference types
+ template<typename _Tp>
+ class allocator<_Tp&> : public allocator<_Tp>
+ {
+#if __cplusplus >= 201103L
+ public:
+ allocator()
+ {
+ static_assert( is_object<_Tp&>::value,
+ "allocator's value_type must be an object type" );
+ }
+#else
+ private:
+ allocator();
+#endif
+ };
+
template<typename _T1, typename _T2>
inline bool
operator==(const allocator<_T1>&, const allocator<_T2>&)
new file mode 100644
@@ -0,0 +1,27 @@
+// Copyright (C) 2013 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/>.
+
+// 17.6.3.5 Allocator requirements
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+
+#include <memory>
+
+std::allocator<int&> a1; // { dg-error "here" }
+// { dg-prune-output "must be an object type" }
+std::allocator<const int> a2; // { dg-error "here" }
+// { dg-prune-output "must be non-const" }