[libcxx-commits] [PATCH] D125518: allocator<const T> is ill-formed

Igor Zhukov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu May 12 20:54:57 PDT 2022


fsb4000 created this revision.
fsb4000 added a project: libc++.
Herald added a project: All.
fsb4000 requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

I noticed that MS STL and libstdc++ already forbid this, so I decided do the same for libc++.

https://gcc.godbolt.org/z/3WsT4j3c1


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125518

Files:
  libcxx/include/__memory/allocator.h


Index: libcxx/include/__memory/allocator.h
===================================================================
--- libcxx/include/__memory/allocator.h
+++ libcxx/include/__memory/allocator.h
@@ -81,6 +81,7 @@
 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");
 public:
     typedef size_t      size_type;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125518.429134.patch
Type: text/x-patch
Size: 552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220513/62791a5e/attachment.bin>


More information about the libcxx-commits mailing list