15 #ifndef RCLCPP__ALLOCATOR__ALLOCATOR_DELETER_HPP_ 16 #define RCLCPP__ALLOCATOR__ALLOCATOR_DELETER_HPP_ 26 template<
typename Allocator>
30 using AllocRebind =
typename std::allocator_traits<Allocator>::template rebind_alloc<T>;
52 std::allocator_traits<AllocRebind<T>>::destroy(*allocator_, ptr);
53 std::allocator_traits<AllocRebind<T>>::deallocate(*allocator_, ptr, 1);
68 Allocator * allocator_;
71 template<
typename Alloc,
typename T,
typename D>
76 throw std::runtime_error(
"Reached unexpected template specialization");
79 template<
typename T,
typename U>
86 template<
typename Alloc,
typename T>
89 if (!deleter || !alloc) {
90 throw std::invalid_argument(
"Argument was NULL to set_allocator_for_deleter");
95 template<
typename Alloc,
typename T>
96 using Deleter =
typename std::conditional<
97 std::is_same<typename std::allocator_traits<Alloc>::template rebind_alloc<T>,
98 typename std::allocator<void>::template rebind<T>::other>::value,
99 std::default_delete<T>,
105 #endif // RCLCPP__ALLOCATOR__ALLOCATOR_DELETER_HPP_ AllocatorDeleter()
Definition: allocator_deleter.hpp:33
Definition: allocator_common.hpp:24
AllocatorDeleter(Allocator *a)
Definition: allocator_deleter.hpp:38
Allocator * get_allocator() const
Definition: allocator_deleter.hpp:57
void set_allocator_for_deleter(D *deleter, Alloc *alloc)
Definition: allocator_deleter.hpp:72
Definition: allocator_deleter.hpp:27
void set_allocator(Allocator *alloc)
Definition: allocator_deleter.hpp:62
AllocatorDeleter(const AllocatorDeleter< T > &a)
Definition: allocator_deleter.hpp:44
void operator()(T *ptr)
Definition: allocator_deleter.hpp:50
typename std::conditional< std::is_same< typename std::allocator_traits< Alloc >::template rebind_alloc< T >, typename std::allocator< void >::template rebind< T >::other >::value, std::default_delete< T >, AllocatorDeleter< Alloc > >::type Deleter
Definition: allocator_deleter.hpp:101