diff options
author | Jonathan Wakely <jwakely.gcc@gmail.com> | 2011-10-04 20:34:54 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely.gcc@gmail.com> | 2011-10-04 20:34:54 +0000 |
commit | 80e0dc15f0cb0f9338728c7c69d529f3dba62fd3 (patch) | |
tree | 483c6f7252fc7d791893fd151de372b8053ad8e8 /libstdc++-v3/include | |
parent | 4d6a59d711df3c4bc433a4615ad1a54223ef8d7c (diff) |
2011-10-04 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/ext/alloc_traits.h (__alloc_traits::max_size): Define.
(__alloc_traits::rebind): Define.
* include/bits/stl_vector.h: Use them.
* testsuite/util/testsuite_allocator.h (SimpleAllocator): Define.
* testsuite/23_containers/vector/allocator/minimal.cc: New.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
Adjust dg-error line numbers.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@179523 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/bits/stl_vector.h | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/ext/alloc_traits.h | 13 |
2 files changed, 16 insertions, 2 deletions
diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 40664209fab..869bcf74489 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -70,7 +70,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Tp, typename _Alloc> struct _Vector_base { - typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type; + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_Tp>::other _Tp_alloc_type; typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer pointer; @@ -643,7 +644,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER /** Returns the size() of the largest possible %vector. */ size_type max_size() const _GLIBCXX_NOEXCEPT - { return _M_get_Tp_allocator().max_size(); } + { return _Alloc_traits::max_size(_M_get_Tp_allocator()); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ /** diff --git a/libstdc++-v3/include/ext/alloc_traits.h b/libstdc++-v3/include/ext/alloc_traits.h index dbeb95f313c..de13b652521 100644 --- a/libstdc++-v3/include/ext/alloc_traits.h +++ b/libstdc++-v3/include/ext/alloc_traits.h @@ -106,6 +106,7 @@ template<typename _Alloc> using _Base_type::deallocate; using _Base_type::construct; using _Base_type::destroy; + using _Base_type::max_size; private: template<typename _Ptr> @@ -115,6 +116,7 @@ template<typename _Alloc> { }; public: + // overload construct for non-standard pointer types template<typename _Ptr, typename... _Args> static typename std::enable_if<__is_custom_pointer<_Ptr>::value>::type construct(_Alloc& __a, _Ptr __p, _Args&&... __args) @@ -123,6 +125,7 @@ template<typename _Alloc> std::forward<_Args>(__args)...); } + // overload destroy for non-standard pointer types template<typename _Ptr> static typename std::enable_if<__is_custom_pointer<_Ptr>::value>::type destroy(_Alloc& __a, _Ptr __p) @@ -156,6 +159,9 @@ template<typename _Alloc> || noexcept(swap(std::declval<_Alloc&>(), std::declval<_Alloc&>())); } + template<typename _Tp> + struct rebind + { typedef typename _Base_type::template __rebind_alloc<_Tp>::__type other; }; #else typedef typename _Alloc::pointer pointer; @@ -179,6 +185,9 @@ template<typename _Alloc> static void destroy(_Alloc& __a, pointer __p) { __a.destroy(__p); } + static size_type max_size(const _Alloc& __a) + { return __a.max_size(); } + static const _Alloc& _S_select_on_copy(const _Alloc& __a) { return __a; } static void _S_on_swap(_Alloc& __a, _Alloc& __b) @@ -187,6 +196,10 @@ template<typename _Alloc> // 431. Swapping containers with unequal allocators. std::__alloc_swap<_Alloc>::_S_do_it(__a, __b); } + + template<typename _Tp> + struct rebind + { typedef typename _Alloc::template rebind<_Tp>::other other; }; #endif }; |