mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
add: [pmr] is_memory_resource
This commit is contained in:
parent
4c9c8bb875
commit
cc17980b97
@ -36,6 +36,11 @@ struct has_deallocate<T,
|
|||||||
std::declval<std::size_t>()))
|
std::declval<std::size_t>()))
|
||||||
> : std::true_type {};
|
> : std::true_type {};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using is_memory_resource =
|
||||||
|
typename std::enable_if<has_allocate <T>::value &&
|
||||||
|
has_deallocate<T>::value>::type;
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -17,6 +17,15 @@ TEST(allocator, detail) {
|
|||||||
EXPECT_TRUE (pmr::detail::has_allocate<std::pmr::memory_resource>::value);
|
EXPECT_TRUE (pmr::detail::has_allocate<std::pmr::memory_resource>::value);
|
||||||
EXPECT_TRUE (pmr::detail::has_allocate<std::pmr::polymorphic_allocator<int>>::value);
|
EXPECT_TRUE (pmr::detail::has_allocate<std::pmr::polymorphic_allocator<int>>::value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
EXPECT_FALSE(pmr::detail::has_deallocate<void>::value);
|
||||||
|
EXPECT_FALSE(pmr::detail::has_deallocate<int>::value);
|
||||||
|
EXPECT_FALSE(pmr::detail::has_deallocate<std::vector<int>>::value);
|
||||||
|
EXPECT_FALSE(pmr::detail::has_deallocate<std::allocator<int>>::value);
|
||||||
|
#if defined(LIBIMP_CPP_17) && defined(__cpp_lib_memory_resource)
|
||||||
|
EXPECT_TRUE (pmr::detail::has_deallocate<std::pmr::memory_resource>::value);
|
||||||
|
EXPECT_FALSE(pmr::detail::has_deallocate<std::pmr::polymorphic_allocator<int>>::value);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(allocator, construct) {
|
TEST(allocator, construct) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user