Index: include/memory =================================================================== --- include/memory +++ include/memory @@ -2522,6 +2522,13 @@ // default_delete +template struct __do_default_delete; +template struct __do_default_delete<_Tp, true> +{ void operator() (_Tp* __ptr) const _NOEXCEPT { delete [] __ptr; }}; + +template struct __do_default_delete<_Tp, false> +{ void operator() (_Tp* __ptr) const _NOEXCEPT { delete __ptr; }}; + template struct _LIBCPP_TYPE_VIS_ONLY default_delete { @@ -2533,11 +2540,13 @@ template _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up>&, typename enable_if::value>::type* = 0) _NOEXCEPT {} - _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const _NOEXCEPT + + _LIBCPP_INLINE_VISIBILITY void + operator() (_Tp* __ptr) const _NOEXCEPT { static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type"); - delete __ptr; + __do_default_delete<_Tp, is_array<_Tp>::value>()(__ptr); } };