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>;
46 allocator_ = a.get_allocator();
50 void operator()(T * ptr)
52 std::allocator_traits<AllocRebind<T>>::destroy(*allocator_, ptr);
53 std::allocator_traits<AllocRebind<T>>::deallocate(*allocator_, ptr, 1);
57 Allocator * get_allocator()
const
62 void set_allocator(Allocator * alloc)
68 Allocator * allocator_;
71 template<
typename Alloc,
typename T,
typename D>
72 void set_allocator_for_deleter(D * deleter, Alloc * alloc)
76 throw std::runtime_error(
"Reached unexpected template specialization");
79 template<
typename T,
typename U>
80 void set_allocator_for_deleter(std::default_delete<T> * deleter, std::allocator<U> * alloc)
86 template<
typename Alloc,
typename T>
87 void set_allocator_for_deleter(AllocatorDeleter<T> * deleter, Alloc * alloc)
89 if (!deleter || !alloc) {
90 throw std::invalid_argument(
"Argument was NULL to set_allocator_for_deleter");
92 deleter->set_allocator(alloc);
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 std::allocator<T>>::value,
99 std::default_delete<T>,
100 AllocatorDeleter<Alloc>
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.