From 677aad9c92d346e6cfea943445c2d04a4a4c8cea Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Sat, 9 Jul 2011 13:45:56 +0000 Subject: [PATCH] Makefile.am: Add new header. 2011-07-09 Jonathan Wakely * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/std/scoped_allocator: New. * doc/xml/manual/status_cxx200x.xml: Update. * testsuite/20_util/scoped_allocator/1.cc: New. * testsuite/20_util/scoped_allocator/propagation.cc: New. * testsuite/20_util/scoped_allocator/requirements/typedefs.cc: New. * testsuite/20_util/scoped_allocator/requirements/ explicit_instantiation.cc: New. From-SVN: r176079 --- libstdc++-v3/ChangeLog | 12 + .../doc/xml/manual/status_cxx200x.xml | 21 +- libstdc++-v3/include/Makefile.am | 1 + libstdc++-v3/include/Makefile.in | 1 + libstdc++-v3/include/std/scoped_allocator | 373 ++++++++++++++++++ .../testsuite/20_util/scoped_allocator/1.cc | 99 +++++ .../20_util/scoped_allocator/propagation.cc | 105 +++++ .../requirements/explicit_instantiation.cc | 47 +++ .../scoped_allocator/requirements/typedefs.cc | 67 ++++ 9 files changed, 713 insertions(+), 13 deletions(-) create mode 100644 libstdc++-v3/include/std/scoped_allocator create mode 100644 libstdc++-v3/testsuite/20_util/scoped_allocator/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/scoped_allocator/propagation.cc create mode 100644 libstdc++-v3/testsuite/20_util/scoped_allocator/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/scoped_allocator/requirements/typedefs.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1304b9241e2..6424c558ace 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,15 @@ +2011-07-09 Jonathan Wakely + + * include/Makefile.am: Add new header. + * include/Makefile.in: Regenerate. + * include/std/scoped_allocator: New. + * doc/xml/manual/status_cxx200x.xml: Update. + * testsuite/20_util/scoped_allocator/1.cc: New. + * testsuite/20_util/scoped_allocator/propagation.cc: New. + * testsuite/20_util/scoped_allocator/requirements/typedefs.cc: New. + * testsuite/20_util/scoped_allocator/requirements/ + explicit_instantiation.cc: New. + 2011-07-09 Jonathan Wakely * include/bits/stl_vector.h: Use new allocator model in C++0x mode. diff --git a/libstdc++-v3/doc/xml/manual/status_cxx200x.xml b/libstdc++-v3/doc/xml/manual/status_cxx200x.xml index 5c4bc5de0bd..88e238f2355 100644 --- a/libstdc++-v3/doc/xml/manual/status_cxx200x.xml +++ b/libstdc++-v3/doc/xml/manual/status_cxx200x.xml @@ -1009,52 +1009,47 @@ particular release. - + 20.12 Scoped allocator adaptor - + Partial - 20.12.1 Header <scoped_allocator> synopsis - 20.12.2 Scoped allocator adaptor member types - N + Y - 20.12.3 Scoped allocator adaptor constructors - N + Y - + 20.12.4 Scoped allocator adaptor members - N + Partial - 20.12.5 Scoped allocator operators - N + Y - 20.13 Class type_index - N + Y diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index b6a0116872f..c926a3133aa 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -58,6 +58,7 @@ std_headers = \ ${std_srcdir}/random \ ${std_srcdir}/ratio \ ${std_srcdir}/regex \ + ${std_srcdir}/scoped_allocator \ ${std_srcdir}/set \ ${std_srcdir}/sstream \ ${std_srcdir}/stack \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 750e67f89f4..c26eab0c6a0 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -310,6 +310,7 @@ std_headers = \ ${std_srcdir}/random \ ${std_srcdir}/ratio \ ${std_srcdir}/regex \ + ${std_srcdir}/scoped_allocator \ ${std_srcdir}/set \ ${std_srcdir}/sstream \ ${std_srcdir}/stack \ diff --git a/libstdc++-v3/include/std/scoped_allocator b/libstdc++-v3/include/std/scoped_allocator new file mode 100644 index 00000000000..bde996c42b3 --- /dev/null +++ b/libstdc++-v3/include/std/scoped_allocator @@ -0,0 +1,373 @@ +// -*- C++ -*- + +// Copyright (C) 2011 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/scoped_allocator + * This is a Standard C++ Library header. + */ + +#ifndef _SCOPED_ALLOCATOR +#define _SCOPED_ALLOCATOR 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include +#else + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template class _Pred, typename... _Allocs> + struct __any_of; + + template class _Pred, typename _Alloc, typename... _Allocs> + struct __any_of<_Pred, _Alloc, _Allocs...> + : __or_<_Pred<_Alloc>, __any_of<_Pred, _Allocs...>> + { }; + + template class _Pred, typename _Alloc> + struct __any_of<_Pred, _Alloc> + : _Pred<_Alloc> + { }; + + /** + * @addtogroup allocators + * @{ + */ + + template + struct __propagate_on_copy + : allocator_traits<_Alloc>::propagate_on_container_copy_assignment + { }; + template + struct __propagate_on_move + : allocator_traits<_Alloc>::propagate_on_container_move_assignment + { }; + template + struct __propagate_on_swap + : allocator_traits<_Alloc>::propagate_on_container_swap + { }; + + + template + inline auto + __do_outermost(_Alloc& __a, _Alloc&) -> decltype(__a.outer_allocator()) + { return __a.outer_allocator(); } + + template + inline _Alloc& + __do_outermost(_Alloc& __a, ...) + { return __a; } + + template + inline auto + __outermost(_Alloc& __a) -> decltype(__do_outermost(__a, __a)) + { return __do_outermost(__a, __a); } + + template + class scoped_allocator_adaptor; + + template struct __inner_type_impl; + + template + struct __inner_type_impl<_Outer> + { + typedef scoped_allocator_adaptor<_Outer> __type; + + __inner_type_impl() = default; + __inner_type_impl(const __inner_type_impl&) = default; + __inner_type_impl(__inner_type_impl&&) = default; + + template + __inner_type_impl(const __inner_type_impl<_Alloc>& __other) + { } + + template + __inner_type_impl(__inner_type_impl<_Alloc>&& __other) + { } + + __type& _M_get(__type* __p) noexcept { return *__p; } + const __type& _M_get(const __type* __p) const noexcept { return *__p; } + + tuple<> _M_tie() const noexcept { return tuple<>(); } + + bool operator==(const __inner_type_impl&) const noexcept + { return true; } + }; + + template + struct __inner_type_impl<_Outer, _InnerHead, _InnerTail...> + { + typedef scoped_allocator_adaptor<_InnerHead, _InnerTail...> __type; + + __inner_type_impl() = default; + __inner_type_impl(const __inner_type_impl&) = default; + __inner_type_impl(__inner_type_impl&&) = default; + + template + __inner_type_impl(const __inner_type_impl<_Allocs...>& __other) + : _M_inner(__other._M_inner) { } + + template + __inner_type_impl(__inner_type_impl<_Allocs...>&& __other) + : _M_inner(std::move(__other._M_inner)) { } + + template + explicit + __inner_type_impl(_Args&&... __args) + : _M_inner(std::forward<_Args>(__args)...) { } + + __type& _M_get(void*) noexcept { return _M_inner; } + const __type& _M_get(const void*) const noexcept { return _M_inner; } + + tuple _M_tie() const noexcept + { return _M_inner._M_tie(); } + + bool operator==(const __inner_type_impl& __other) const noexcept + { return _M_inner == __other._M_inner; } + + private: + template friend class __inner_type_impl; + template friend class scoped_allocator_adaptor; + + __type _M_inner; + }; + + template + class scoped_allocator_adaptor + : public _OuterAlloc + { + typedef allocator_traits<_OuterAlloc> __traits; + + typedef __inner_type_impl<_OuterAlloc, _InnerAllocs...> __inner_type; + __inner_type _M_inner; + + template + friend class scoped_allocator_adaptor; + + template + friend class __inner_type_impl; + + tuple + _M_tie() const noexcept + { return std::tuple_cat(std::tie(outer_allocator()), _M_inner._M_tie()); } + + + template + void _M_construct(__uses_alloc0, _Tp* __p, _Args&&... __args) + { + auto& __outer = __outermost(*this); + typedef typename std::decay::type __outer_type; + typedef allocator_traits<__outer_type> __o_traits; + __o_traits::construct(__outer, __p, std::forward<_Args>(__args)...); + } + + typedef __uses_alloc1 __uses_alloc1_; + typedef __uses_alloc2 __uses_alloc2_; + + template + void _M_construct(__uses_alloc1_, _Tp* __p, _Args&&... __args) + { + auto& __outer = __outermost(*this); + typedef typename std::decay::type __outer_type; + typedef allocator_traits<__outer_type> __o_traits; + __o_traits::construct(__outer, __p, allocator_arg, inner_allocator(), + std::forward<_Args>(__args)...); + } + + template + void _M_construct(__uses_alloc2_, _Tp* __p, _Args&&... __args) + { + auto& __outer = __outermost(*this); + typedef typename std::decay::type __outer_type; + typedef allocator_traits<__outer_type> __o_traits; + __o_traits::construct(__outer, __p, std::forward<_Args>(__args)..., + inner_allocator()); + } + + template + static _Alloc + _S_select_on_copy(const _Alloc& __a) + { + typedef allocator_traits<_Alloc> __a_traits; + return __a_traits::select_on_container_copy_construction(__a); + } + + template + scoped_allocator_adaptor(tuple __refs, + _Index_tuple<_Indices...>) + : _OuterAlloc(_S_select_on_copy(std::get<0>(__refs))), + _M_inner(_S_select_on_copy(std::get<_Indices+1>(__refs))...) + { } + + public: + typedef _OuterAlloc outer_allocator_type; + typedef typename __inner_type::__type inner_allocator_type; + + typedef typename __traits::value_type value_type; + typedef typename __traits::size_type size_type; + typedef typename __traits::difference_type difference_type; + typedef typename __traits::pointer pointer; + typedef typename __traits::const_pointer const_pointer; + typedef typename __traits::void_pointer void_pointer; + typedef typename __traits::const_void_pointer const_void_pointer; + + typedef typename conditional< + __any_of<__propagate_on_copy, _OuterAlloc, _InnerAllocs...>::value, + true_type, false_type>::type propagate_on_container_copy_assignment; + typedef typename conditional< + __any_of<__propagate_on_move, _OuterAlloc, _InnerAllocs...>::value, + true_type, false_type>::type propagate_on_container_move_assignment; + typedef typename conditional< + __any_of<__propagate_on_swap, _OuterAlloc, _InnerAllocs...>::value, + true_type, false_type>::type propagate_on_container_swap; + + template + struct rebind + { + // TODO: use rebind_alloc instead of __rebind_alloc::__type + typedef scoped_allocator_adaptor< + typename __traits::template __rebind_alloc<_Tp>::__type, + _InnerAllocs...> other; + }; + + scoped_allocator_adaptor() : _OuterAlloc(), _M_inner() { } + + template + scoped_allocator_adaptor(_Outer2&& __outer, + const _InnerAllocs&... __inner) + : _OuterAlloc(std::forward<_Outer2>(__outer)), + _M_inner(__inner...) + { } + + scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) + : _OuterAlloc(__other.outer_allocator()), + _M_inner(__other._M_inner) + { } + + scoped_allocator_adaptor(scoped_allocator_adaptor&& __other) + : _OuterAlloc(std::move(__other.outer_allocator())), + _M_inner(std::move(__other._M_inner)) + { } + + template + scoped_allocator_adaptor( + const scoped_allocator_adaptor<_Outer2, _InnerAllocs...>& __other) + : _OuterAlloc(__other.outer_allocator()), + _M_inner(__other._M_inner) + { } + + template + scoped_allocator_adaptor( + scoped_allocator_adaptor<_Outer2, _InnerAllocs...>&& __other) + : _OuterAlloc(std::move(__other.outer_allocator())), + _M_inner(std::move(__other._M_inner)) + { } + + inner_allocator_type& inner_allocator() noexcept + { return _M_inner._M_get(this); } + + const inner_allocator_type& inner_allocator() const noexcept + { return _M_inner._M_get(this); } + + outer_allocator_type& outer_allocator() noexcept + { return static_cast<_OuterAlloc&>(*this); } + + const outer_allocator_type& outer_allocator() const noexcept + { return static_cast(*this); } + + pointer allocate(size_type __n) + { return __traits::allocate(outer_allocator(), __n); } + + pointer allocate(size_type __n, const_void_pointer __hint) + { return __traits::allocate(outer_allocator(), __n, __hint); } + + void deallocate(pointer __p, size_type __n) + { return __traits::deallocate(outer_allocator(), __p, __n); } + + size_type max_size() const + { return __traits::max_size(outer_allocator()); } + + template + void construct(_Tp* __p, _Args&&... __args) + { + auto& __inner = inner_allocator(); + auto __use_tag + = __use_alloc<_Tp, inner_allocator_type, _Args...>(__inner); + _M_construct(__use_tag, __p, std::forward<_Args>(__args)...); + } + + // TODO: construct pairs + + template + void destroy(_Tp* __p) + { + auto& __outer = __outermost(*this); + typedef typename std::decay::type __outer_type; + allocator_traits<__outer_type>::destroy(__outer, __p); + } + + scoped_allocator_adaptor + select_on_container_copy_construction() const + { + typedef typename _Build_index_tuple::__type + _Indices; + return scoped_allocator_adaptor(_M_tie(), _Indices()); + } + + template + friend bool + operator==(const scoped_allocator_adaptor<_OutA1, _InA...>& __a, + const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept; + }; + + template + inline bool + operator==(const scoped_allocator_adaptor<_OutA1, _InA...>& __a, + const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept + { + return __a.outer_allocator() == __b.outer_allocator() + && __a._M_inner == __b._M_inner; + } + + template + inline bool + operator!=(const scoped_allocator_adaptor<_OutA1, _InA...>& __a, + const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept + { return !(__a == __b); } + + /// @} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _SCOPED_ALLOCATOR diff --git a/libstdc++-v3/testsuite/20_util/scoped_allocator/1.cc b/libstdc++-v3/testsuite/20_util/scoped_allocator/1.cc new file mode 100644 index 00000000000..823769fb563 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/scoped_allocator/1.cc @@ -0,0 +1,99 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 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 +// . + +#include +#include +#include +#include +#include + +using __gnu_test::uneq_allocator; + +struct Element +{ + typedef uneq_allocator allocator_type; + + allocator_type alloc; + + Element(const allocator_type& a = allocator_type()) : alloc(a) { } + + Element(std::allocator_arg_t, const allocator_type& a, int i = 0) + : alloc(a) { } + + Element(std::allocator_arg_t, const allocator_type& a, const Element&) + : alloc(a) { } + + const allocator_type& get_allocator() const { return alloc; } +}; + +void test01() +{ + bool test __attribute((unused)) = false; + + typedef std::scoped_allocator_adaptor alloc1_type; + + typedef std::vector EltVec; + + alloc1_type a1(1); + Element e; + EltVec ev1(1, e, a1); + VERIFY( ev1[0].get_allocator().get_personality() == 1 ); +} + +void test02() +{ + bool test __attribute((unused)) = false; + + typedef std::vector EltVec; + + typedef std::scoped_allocator_adaptor alloc_type; + + typedef std::vector EltVecVec; + + alloc_type a(1, 2); + Element e; + EltVec ev(1, e); + EltVecVec evv(1, ev, a); + + VERIFY( evv.get_allocator().get_personality() == 1 ); + VERIFY( evv[0].get_allocator().get_personality() == 2 ); + VERIFY( evv[0][0].get_allocator().get_personality() == 2 ); + + alloc_type a2(3, 4); + + EltVecVec evv2(evv, a2); // copy with a different allocator + + VERIFY( evv2.get_allocator().get_personality() == 3 ); + VERIFY( evv2[0].get_allocator().get_personality() == 4 ); + VERIFY( evv2[0][0].get_allocator().get_personality() == 4 ); + + EltVecVec evv3(std::move(evv), a2); // move with a different allocator + + VERIFY( evv3.get_allocator().get_personality() == 3 ); + VERIFY( evv3[0].get_allocator().get_personality() == 4 ); + VERIFY( evv3[0][0].get_allocator().get_personality() == 4 ); + +} + + +int main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/20_util/scoped_allocator/propagation.cc b/libstdc++-v3/testsuite/20_util/scoped_allocator/propagation.cc new file mode 100644 index 00000000000..5679b733715 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/scoped_allocator/propagation.cc @@ -0,0 +1,105 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 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 +// . + +// test that propagate_on_container_xxx is true iff it is true for +// any of the outer or inner allocators + +#include + +using std::scoped_allocator_adaptor; + +typedef short test_type; + +template + struct minimal_allocator + { + typedef T value_type; + minimal_allocator(); + template + minimal_allocator(const minimal_allocator&); + T* allocate(std::size_t); + void deallocate(T*, std::size_t); + }; + +template + struct test_allocator : minimal_allocator + { + struct propagate_on_container_copy_assignment + { static const bool value = copy; }; + + struct propagate_on_container_move_assignment + { static const bool value = move; }; + + struct propagate_on_container_swap + { static const bool value = swap; }; + }; + +template + constexpr bool prop_on_copy() + { + typedef typename A::propagate_on_container_copy_assignment type; + return type::value; + } + +template + constexpr bool prop_on_move() + { + typedef typename A::propagate_on_container_move_assignment type; + return type::value; + } + +template + constexpr bool prop_on_swap() + { + typedef typename A::propagate_on_container_swap type; + return type::value; + } + +template + constexpr bool test1() + { + static_assert( prop_on_copy() == C, "copy" ); + static_assert( prop_on_move() == M, "move" ); + static_assert( prop_on_swap() == S, "swap" ); + return true; + } + +template + constexpr bool test2() + { + typedef minimal_allocator base_alloc; + typedef test_allocator test_alloc; + typedef scoped_allocator_adaptor scoped1; + typedef scoped_allocator_adaptor scoped2; + typedef scoped_allocator_adaptor scoped3; + return test1() + && test1() + && test1(); + } + +static_assert( test2(), "never propagate" ); +static_assert( test2(), "propagate on copy" ); +static_assert( test2(), "propagate on move" ); +static_assert( test2(), "propagate on swap" ); +static_assert( test2(), "propagate on copy & move" ); +static_assert( test2(), "propagate on copy & swap" ); +static_assert( test2(), "propagate on move & swap" ); +static_assert( test2(), "always propagate" ); + diff --git a/libstdc++-v3/testsuite/20_util/scoped_allocator/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/scoped_allocator/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..1f85756f74a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/scoped_allocator/requirements/explicit_instantiation.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011 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 +// . + +// NB: This file is for testing memory with NO OTHER INCLUDES. + +#include +#include + +typedef short test_type; + +template + struct minimal_allocator + { + typedef T value_type; + minimal_allocator(); + template + minimal_allocator(const minimal_allocator&); + T* allocate(unsigned long); + void deallocate(T*, unsigned long); + }; + +namespace std +{ + template struct scoped_allocator_adaptor>; + + template struct scoped_allocator_adaptor>; + + template struct scoped_allocator_adaptor, + minimal_allocator>; +} diff --git a/libstdc++-v3/testsuite/20_util/scoped_allocator/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/scoped_allocator/requirements/typedefs.cc new file mode 100644 index 00000000000..762bedf8e5c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/scoped_allocator/requirements/typedefs.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011 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 +// . + +// +// NB: This file is for testing scoped_allocator with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +template + struct minimal_allocator + { + typedef T value_type; + minimal_allocator(); + template + minimal_allocator(const minimal_allocator&); + T* allocate(unsigned long); + void deallocate(T*, unsigned long); + }; + +struct S +{ + typedef minimal_allocator allocator_type; + S(const allocator_type&); +}; + +void test01() +{ + typedef minimal_allocator outer_type; + typedef minimal_allocator inner_type; + typedef std::scoped_allocator_adaptor test_type; + + // Check for required typedefs + typedef typename test_type::outer_allocator_type outer_allocator_type; + typedef typename test_type::inner_allocator_type inner_allocator_type; + typedef typename test_type::value_type value_type; + typedef typename test_type::size_type size_type; + typedef typename test_type::difference_type difference_type; + typedef typename test_type::pointer pointer; + typedef typename test_type::const_pointer const_pointer; + typedef typename test_type::void_pointer void_pointer; + typedef typename test_type::const_void_pointer const_void_pointer; + typedef typename test_type::propagate_on_container_copy_assignment + propagate_on_container_copy_assignment; + typedef typename test_type::propagate_on_container_move_assignment + propagate_on_container_move_assignment; + typedef typename test_type::propagate_on_container_swap + propagate_on_container_swap; +} + -- 2.30.2