diff --git a/include/stdexec/__detail/__concepts.hpp b/include/stdexec/__detail/__concepts.hpp index ef07e7141..218fa39a2 100644 --- a/include/stdexec/__detail/__concepts.hpp +++ b/include/stdexec/__detail/__concepts.hpp @@ -271,4 +271,23 @@ namespace STDEXEC { template requires __none_of<_Ty, _Us...> using __unless_one_of_t = _Ty; + + namespace __detail { + template + auto __test_alloc_pointer(int) -> typename _Alloc::pointer; + template + auto __test_alloc_pointer(long) -> typename _Alloc::value_type*; + + template + using __alloc_pointer_t = decltype(__detail::__test_alloc_pointer<__decay_t<_Alloc>>(0)); + } // namespace __detail + + template + concept __allocator_ = // + requires(__decay_t<_Alloc>& __alloc, std::size_t __bytes) { + { __alloc.allocate(__bytes) } -> same_as<__detail::__alloc_pointer_t<_Alloc>>; + __alloc.deallocate(__alloc.allocate(__bytes), __bytes); + } // + && copy_constructible<__decay_t<_Alloc>> // + && equality_comparable<__decay_t<_Alloc>>; } // namespace STDEXEC diff --git a/include/stdexec/__detail/__queries.hpp b/include/stdexec/__detail/__queries.hpp index b127a5618..6830eeb12 100644 --- a/include/stdexec/__detail/__queries.hpp +++ b/include/stdexec/__detail/__queries.hpp @@ -27,10 +27,6 @@ namespace STDEXEC { ////////////////////////////////////////////////////////////////////////////////////////////////// // [exec.queries] namespace __queries { - // TODO: implement allocator concept - template - concept __allocator_c = true; - ////////////////////////////////////////////////////////////////////////////////// // [exec.get.allocator] struct get_allocator_t : __query { @@ -44,7 +40,7 @@ namespace STDEXEC { STDEXEC_ATTRIBUTE(always_inline, host, device) static constexpr void __validate() noexcept { static_assert(__nothrow_callable); - static_assert(__allocator_c<__call_result_t>); + static_assert(__allocator_<__call_result_t>); } STDEXEC_ATTRIBUTE(nodiscard, always_inline, host, device)