Skip to content

Commit 797a15e

Browse files
committed
fix a problem with get_allocator
1 parent 30371f5 commit 797a15e

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

44
SANITIZERS = release debug msan asan usan tsan
5-
.PHONY: default run update check ce todo distclean clean build test all $(SANITIZERS)
5+
.PHONY: default run update check ce todo distclean clean build test all format $(SANITIZERS)
66

77
COMPILER=system
88
CXX_BASE=$(CXX:$(dir $(CXX))%=%)
@@ -79,6 +79,9 @@ check:
7979
< $$h sed -n "/^ *# *include <Beman\//s@.*[</]Beman/\(.*\).hpp>.*@$$from \1@p"; \
8080
done | tsort > /dev/null
8181

82+
format:
83+
clang-format -i `git diff --name-only main | egrep '\.[ch]pp'`
84+
8285
todo:
8386
bin/mk-todo.py
8487

include/beman/execution26/detail/get_allocator.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ struct get_allocator_t {
1919
auto operator()(Object&&) const =
2020
BEMAN_EXECUTION26_DELETE("the object requires a const query(get_allocator_t) overload");
2121
template <typename Object>
22-
requires(not requires(const Object& object, const get_allocator_t& tag) { object.query(tag); })
22+
requires(
23+
not requires(const Object& object, const get_allocator_t& tag) { object.query(tag); } &&
24+
not requires(Object&& object, const get_allocator_t& tag) { ::std::as_const(object).query(tag); })
2325
auto
2426
operator()(Object&&) const = BEMAN_EXECUTION26_DELETE("the object requires a query(get_allocator_t) overload");
2527
template <typename Object>
@@ -28,6 +30,7 @@ struct get_allocator_t {
2830
})
2931
auto
3032
operator()(Object&&) const = BEMAN_EXECUTION26_DELETE("the query(get_allocator_t) overload needs to be noexcept");
33+
3134
template <typename Object>
3235
requires(not requires(const Object& object, const get_allocator_t& tag) {
3336
{ object.query(tag) } noexcept -> ::beman::execution26::detail::simple_allocator<>;
@@ -36,7 +39,10 @@ struct get_allocator_t {
3639
operator()(Object&&) const = BEMAN_EXECUTION26_DELETE("the query(get_allocator_t) overload needs to be noexcept");
3740

3841
template <typename Object>
39-
auto operator()(Object&& object) const {
42+
requires(requires(const Object& object, const get_allocator_t& tag) {
43+
{ object.query(tag) } noexcept -> ::beman::execution26::detail::simple_allocator<>;
44+
})
45+
auto operator()(Object&& object) const noexcept {
4046
return ::std::as_const(object).query(*this);
4147
}
4248

include/beman/execution26/detail/simple_allocator.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
// ----------------------------------------------------------------------------
1111

1212
namespace beman::execution26::detail {
13-
template <typename Alloc = bool>
14-
concept simple_allocator = requires(Alloc alloc, ::std::size_t n) {
15-
{ *alloc.allocate(n) } -> ::std::same_as<typename Alloc::value_type&>;
16-
alloc.deallocate(alloc.allocate(n), n);
17-
} && ::std::copy_constructible<Alloc> && ::std::equality_comparable<Alloc>;
13+
template <typename Alloc>
14+
concept simple_allocator =
15+
requires(::std::remove_cvref_t<Alloc> alloc, ::std::size_t n) {
16+
{ *alloc.allocate(n) } -> ::std::same_as<typename ::std::remove_cvref_t<Alloc>::value_type&>;
17+
alloc.deallocate(alloc.allocate(n), n);
18+
} && ::std::copy_constructible<::std::remove_cvref_t<Alloc>> &&
19+
::std::equality_comparable<::std::remove_cvref_t<Alloc>>;
1820
} // namespace beman::execution26::detail
1921

2022
// ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)