diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2016-09-03 18:39:34 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2016-09-03 18:39:34 +0000 |
commit | a8362e751db7934ac79c0fbaa00db7064c170daf (patch) | |
tree | d7ae63863aeb47c84a89fb58d5e3aeabb1d16a7d | |
parent | ccea43bcfcd51e171e31e237f380cfbb5ae8d0fb (diff) |
Import libc++ 3.9.0
-rw-r--r-- | lib/libcxx/include/experimental/dynarray | 66 |
1 files changed, 41 insertions, 25 deletions
diff --git a/lib/libcxx/include/experimental/dynarray b/lib/libcxx/include/experimental/dynarray index a60c87c3f97..4a06908e11b 100644 --- a/lib/libcxx/include/experimental/dynarray +++ b/lib/libcxx/include/experimental/dynarray @@ -11,6 +11,9 @@ #ifndef _LIBCPP_DYNARRAY #define _LIBCPP_DYNARRAY +#include <__config> +#if _LIBCPP_STD_VER > 11 + /* dynarray synopsis @@ -93,8 +96,6 @@ public: }} // std::experimental */ -#include <__config> -#if _LIBCPP_STD_VER > 11 #include <__functional_base> #include <iterator> @@ -103,17 +104,20 @@ public: #include <new> #include <algorithm> +#include <__undef___deallocate> + +#if defined(_LIBCPP_NO_EXCEPTIONS) + #include <cassert> +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - namespace std { namespace experimental { inline namespace __array_extensions_v1 { template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_DYNARRAY dynarray +struct _LIBCPP_TYPE_VIS_ONLY dynarray { public: // types: @@ -133,20 +137,24 @@ public: private: size_t __size_; value_type * __base_; - _LIBCPP_INLINE_VISIBILITY dynarray () noexcept : __size_(0), __base_(nullptr) {} + _LIBCPP_ALWAYS_INLINE dynarray () noexcept : __size_(0), __base_(nullptr) {} - static inline _LIBCPP_INLINE_VISIBILITY - value_type* __allocate(size_t __count) { - if (numeric_limits<size_t>::max() / sizeof (value_type) <= __count) - __throw_bad_array_length(); - - return static_cast<value_type *>( - _VSTD::__libcpp_allocate(sizeof(value_type) * __count, __alignof(value_type))); + static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count ) + { + if ( numeric_limits<size_t>::max() / sizeof (value_type) <= count ) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_array_length(); +#else + assert(!"dynarray::allocation"); +#endif + } + return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count)); } - static inline _LIBCPP_INLINE_VISIBILITY - void __deallocate_value(value_type* __ptr ) noexcept { - _VSTD::__libcpp_deallocate(static_cast<void *>(__ptr), __alignof(value_type)); + static inline _LIBCPP_INLINE_VISIBILITY void __deallocate ( value_type* __ptr ) noexcept + { + _VSTD::__deallocate (static_cast<void *> (__ptr)); } public: @@ -266,7 +274,7 @@ dynarray<_Tp>::~dynarray() value_type *__data = data () + __size_; for ( size_t i = 0; i < __size_; ++i ) (--__data)->value_type::~value_type(); - __deallocate_value( __base_ ); + __deallocate ( __base_ ); } template <class _Tp> @@ -275,8 +283,13 @@ typename dynarray<_Tp>::reference dynarray<_Tp>::at(size_type __n) { if (__n >= __size_) - __throw_out_of_range("dynarray::at"); - + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw out_of_range("dynarray::at"); +#else + assert(!"dynarray::at out_of_range"); +#endif + } return data()[__n]; } @@ -286,8 +299,13 @@ typename dynarray<_Tp>::const_reference dynarray<_Tp>::at(size_type __n) const { if (__n >= __size_) - __throw_out_of_range("dynarray::at"); - + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw out_of_range("dynarray::at"); +#else + assert(!"dynarray::at out_of_range"); +#endif + } return data()[__n]; } @@ -296,10 +314,8 @@ dynarray<_Tp>::at(size_type __n) const _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp, class _Alloc> -struct _LIBCPP_TEMPLATE_VIS uses_allocator<std::experimental::dynarray<_Tp>, _Alloc> : true_type {}; +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<std::experimental::dynarray<_Tp>, _Alloc> : true_type {}; _LIBCPP_END_NAMESPACE_STD -_LIBCPP_POP_MACROS - #endif // if _LIBCPP_STD_VER > 11 #endif // _LIBCPP_DYNARRAY |