[libcxx-commits] [libcxx] [libcxx] changes `__is_allocator` from a struct to a variable or concept (PR #68629)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 9 14:14:24 PDT 2023


================
@@ -21,13 +21,21 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#if _LIBCPP_STD_VER >= 20
+template <class _Alloc>
+concept __is_allocator = requires(_Alloc __a) {
+  typename _Alloc::value_type;
+  __a.allocate(size_t(0));
+};
+#else
 template <typename _Alloc, typename = void, typename = void>
-struct __is_allocator : false_type {};
+inline static const bool __is_allocator = false;
 
 template <typename _Alloc>
-struct __is_allocator<_Alloc,
-                      __void_t<typename _Alloc::value_type>,
-                      __void_t<decltype(std::declval<_Alloc&>().allocate(size_t(0)))> > : true_type {};
+inline static const bool __is_allocator<_Alloc,
+                                        __void_t<typename _Alloc::value_type>,
+                                        __void_t<decltype(std::declval<_Alloc&>().allocate(size_t(0)))> > = true;
----------------
philnik777 wrote:

```suggestion

inline static const bool
    __is_allocator<_Alloc,
                   __void_t<typename _Alloc::value_type, decltype(std::declval<_Alloc&>().allocate(size_t(0)))> > =
        true;
```

We might as well update it while we're at it.

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


More information about the libcxx-commits mailing list