Skip to content

Commit

Permalink
don't depend on <memory_resource>
Browse files Browse the repository at this point in the history
  • Loading branch information
ericniebler committed Nov 1, 2023
1 parent c9a8547 commit da9815f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions include/stdexec/__detail/__config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@
#define STDEXEC_HAS_STD_RANGES() 0
#endif

#if __has_include(<memory_resource>) && \
(defined(__cpp_lib_memory_resource) && __cpp_lib_memory_resource >= 201603L)
#define STDEXEC_HAS_STD_MEMORY_RESOURCE() 1
#else
#define STDEXEC_HAS_STD_MEMORY_RESOURCE() 0
#endif

#ifdef STDEXEC_ASSERT
#error "Redefinition of STDEXEC_ASSERT is not permitted. Define STDEXEC_ASSERT_FN instead."
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/stdexec/__detail/__memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "__scope.hpp"

#include <memory>
#include <memory_resource>
#include <new>

namespace stdexec {
namespace __mem {
Expand Down
9 changes: 9 additions & 0 deletions test/stdexec/algos/consumers/test_start_detached.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
#include <exec/env.hpp>

#include <chrono>

#if STDEXEC_HAS_STD_MEMORY_RESOURCE()
#include <memory_resource>
#endif

namespace ex = stdexec;

Expand Down Expand Up @@ -162,6 +165,9 @@ namespace {
CHECK_FALSE(called);
}

#if STDEXEC_HAS_STD_MEMORY_RESOURCE() && \
(defined(__cpp_lib_polymorphic_allocator) && __cpp_lib_polymorphic_allocator >= 201902L)

struct counting_resource : std::pmr::memory_resource {
counting_resource() = default;

Expand Down Expand Up @@ -201,5 +207,8 @@ namespace {
CHECK(res.get_count() == 1);
CHECK(res.get_alive() == 0);
}
#endif

}

STDEXEC_PRAGMA_POP()

0 comments on commit da9815f

Please sign in to comment.