diff --git a/include/libpmr/allocator.h b/include/libpmr/allocator.h index f28fc45..c9a279f 100644 --- a/include/libpmr/allocator.h +++ b/include/libpmr/allocator.h @@ -36,6 +36,11 @@ struct has_deallocate())) > : std::true_type {}; +template +using is_memory_resource = + typename std::enable_if::value && + has_deallocate::value>::type; + } // namespace detail /** diff --git a/test/pmr/test_pmr_allocator.cpp b/test/pmr/test_pmr_allocator.cpp index 266e23c..1f3be4f 100644 --- a/test/pmr/test_pmr_allocator.cpp +++ b/test/pmr/test_pmr_allocator.cpp @@ -17,6 +17,15 @@ TEST(allocator, detail) { EXPECT_TRUE (pmr::detail::has_allocate::value); EXPECT_TRUE (pmr::detail::has_allocate>::value); #endif + + EXPECT_FALSE(pmr::detail::has_deallocate::value); + EXPECT_FALSE(pmr::detail::has_deallocate::value); + EXPECT_FALSE(pmr::detail::has_deallocate>::value); + EXPECT_FALSE(pmr::detail::has_deallocate>::value); +#if defined(LIBIMP_CPP_17) && defined(__cpp_lib_memory_resource) + EXPECT_TRUE (pmr::detail::has_deallocate::value); + EXPECT_FALSE(pmr::detail::has_deallocate>::value); +#endif } TEST(allocator, construct) {