[libcxx-commits] [libcxx] [libcxx] improves diagnostics for containers with bad value types (PR #106296)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 29 13:08:42 PDT 2024


================
@@ -76,8 +79,10 @@ struct __non_trivial_if<true, _Unique> {
 
 template <class _Tp>
 class _LIBCPP_TEMPLATE_VIS allocator : private __non_trivial_if<!is_void<_Tp>::value, allocator<_Tp> > {
-  static_assert(!is_const<_Tp>::value, "std::allocator does not support const types");
-  static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types");
+  static_assert(!is_const<_Tp>::value, "'std::allocator' cannot allocate const types");
+  static_assert(!is_volatile<_Tp>::value, "'std::allocator' cannot allocate volatile types");
+  static_assert(!is_reference<_Tp>::value, "'std::allocator' cannot allocate references");
+  static_assert(!is_function<_Tp>::value, "'std::allocator' cannot allocate functions");
----------------
ldionne wrote:

Can we tie these checks back to the Standard wording that says so? It doesn't have to be in the static assert message, but at least in a comment.

https://github.com/llvm/llvm-project/pull/106296


More information about the libcxx-commits mailing list