From 8e892c9dd84a4734c1d5b1285035520f5fb96838 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Wed, 12 Oct 2022 20:24:04 +0200 Subject: [PATCH] [libc++] Improve error message for invalid allocators Reviewed By: ldionne, #libc Spies: libcxx-commits, rupprecht Differential Revision: https://reviews.llvm.org/D135803 --- libcxx/include/__memory/allocator_traits.h | 3 ++- .../sequences/vector/invalid_allocator.verify.cpp | 28 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 libcxx/test/libcxx/containers/sequences/vector/invalid_allocator.verify.cpp diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h index 619fe11..6acc14a 100644 --- a/libcxx/include/__memory/allocator_traits.h +++ b/libcxx/include/__memory/allocator_traits.h @@ -156,7 +156,8 @@ struct __has_rebind_other<_Tp, _Up, __void_t: template ::value> struct __allocator_traits_rebind { - using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other; + static_assert(__has_rebind_other<_Tp, _Up>::value, "This allocator has to implement rebind"); + using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other; }; template