Skip to content

Commit 8d09a47

Browse files
committed
fix allocate constraint in __allocator concept, clang-format
1 parent c27823a commit 8d09a47

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

include/stdexec/__detail/__concepts.hpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,22 @@ namespace stdexec {
272272
requires __none_of<_Ty, _Us...>
273273
using __unless_one_of_t = _Ty;
274274

275+
namespace __detail {
276+
template <class _Alloc>
277+
auto __test_alloc_pointer(int) -> typename _Alloc::pointer;
278+
template <class _Alloc>
279+
auto __test_alloc_pointer(long) -> typename _Alloc::value_type*;
280+
281+
template <class _Alloc>
282+
using __alloc_pointer_t = decltype(__detail::__test_alloc_pointer<__decay_t<_Alloc>>(0));
283+
} // namespace __detail
284+
275285
template <class _Alloc>
276-
concept __allocator =
277-
requires(std::remove_cvref_t<_Alloc> __al, std::size_t __n) {
278-
{
279-
__al.allocate(__n)
280-
} -> same_as<std::add_pointer_t<typename std::remove_cvref_t<_Alloc>::value_type>>;
281-
__al.deallocate(__al.allocate(__n), __n);
282-
} && copy_constructible<std::remove_cvref_t<_Alloc>>
283-
&& equality_comparable<std::remove_cvref_t<_Alloc>>;
286+
concept __allocator = //
287+
requires(__declfn_t<__decay_t<_Alloc>&> __al, std::size_t __n) {
288+
{ __al().allocate(__n) } -> same_as<__detail::__alloc_pointer_t<_Alloc>>;
289+
__al().deallocate(__al().allocate(__n), __n);
290+
} //
291+
&& copy_constructible<__decay_t<_Alloc>> //
292+
&& equality_comparable<__decay_t<_Alloc>>;
284293
} // namespace stdexec

0 commit comments

Comments
 (0)