diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-05-07 03:12:24 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-05-07 03:12:24 +0000 |
commit | 4db388b579686bce48b89d7a82b48561df93e3e9 (patch) | |
tree | f3257b906b004f3fdfa15602cef99bdbca368796 /include/memory | |
parent | dba23b499be925f98fba2345eaacb99b88eba9ea (diff) |
Change allocator<T>::allocate to throw length_error, not bad_alloc
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@268842 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/memory')
-rw-r--r-- | include/memory | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/include/memory b/include/memory index 788830329..8378aef49 100644 --- a/include/memory +++ b/include/memory @@ -607,6 +607,7 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); #include <__functional_base> #include <iosfwd> #include <tuple> +#include <stdexcept> #include <cstring> #if defined(_LIBCPP_NO_EXCEPTIONS) #include <cassert> @@ -1728,11 +1729,8 @@ public: _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) { if (__n > max_size()) -#ifndef _LIBCPP_NO_EXCEPTIONS - throw bad_alloc(); -#else - assert(!"allocator<T>::allocate::bad_alloc"); -#endif + __libcpp_throw(length_error("allocator<T>::allocate(size_t n)" + " 'n' exceeds maximum supported size")); return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp))); } _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT @@ -1827,13 +1825,10 @@ public: _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) { if (__n > max_size()) -#ifndef _LIBCPP_NO_EXCEPTIONS - throw bad_alloc(); -#else - assert(!"allocator<const T>::allocate::bad_alloc"); -#endif + __libcpp_throw(length_error("allocator<const T>::allocate(size_t n)" + " 'n' exceeds maximum supported size")); return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp))); - } + } _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT {_VSTD::__deallocate((void*)__p);} _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT |