15 #ifndef RCLCPP__ALLOCATOR__ALLOCATOR_COMMON_HPP_    16 #define RCLCPP__ALLOCATOR__ALLOCATOR_COMMON_HPP_    29 template<
typename T, 
typename Alloc>
    30 using AllocRebind = 
typename std::allocator_traits<Alloc>::template rebind_traits<T>;
    32 template<
typename Alloc>
    35   auto typed_allocator = 
static_cast<Alloc *
>(untyped_allocator);
    36   if (!typed_allocator) {
    37     throw std::runtime_error(
"Received incorrect allocator type");
    39   return std::allocator_traits<Alloc>::allocate(*typed_allocator, size);
    42 template<
typename T, 
typename Alloc>
    45   auto typed_allocator = 
static_cast<Alloc *
>(untyped_allocator);
    46   if (!typed_allocator) {
    47     throw std::runtime_error(
"Received incorrect allocator type");
    49   auto typed_ptr = 
static_cast<T *
>(untyped_pointer);
    50   std::allocator_traits<Alloc>::deallocate(*typed_allocator, typed_ptr, 1);
    53 template<
typename T, 
typename Alloc>
    56   auto typed_allocator = 
static_cast<Alloc *
>(untyped_allocator);
    57   if (!typed_allocator) {
    58     throw std::runtime_error(
"Received incorrect allocator type");
    60   auto typed_ptr = 
static_cast<T *
>(untyped_pointer);
    61   std::allocator_traits<Alloc>::deallocate(*typed_allocator, typed_ptr, 1);
    62   return std::allocator_traits<Alloc>::allocate(*typed_allocator, size);
    67 template<
typename T, 
typename Alloc,
    68 typename std::enable_if<!std::is_same<Alloc, std::allocator<void>>::value>::type * = 
nullptr>
    73   rcl_allocator.
allocate = &retyped_allocate<Alloc>;
    74   rcl_allocator.
deallocate = &retyped_deallocate<T, Alloc>;
    75   rcl_allocator.
reallocate = &retyped_reallocate<T, Alloc>;
    76   rcl_allocator.
state = &allocator;
    84 template<
typename T, 
typename Alloc,
    85 typename std::enable_if<std::is_same<Alloc, std::allocator<void>>::value>::type * = 
nullptr>
    95 #endif  // RCLCPP__ALLOCATOR__ALLOCATOR_COMMON_HPP_ void retyped_deallocate(void *untyped_pointer, void *untyped_allocator)
Definition: allocator_common.hpp:43
 
void *(* reallocate)(void *pointer, size_t size, void *state)
 
Definition: allocator_common.hpp:24
 
void *(* allocate)(size_t size, void *state)
 
typename std::allocator_traits< Alloc >::template rebind_traits< T > AllocRebind
Definition: allocator_common.hpp:30
 
void * retyped_allocate(size_t size, void *untyped_allocator)
Definition: allocator_common.hpp:33
 
void * retyped_reallocate(void *untyped_pointer, size_t size, void *untyped_allocator)
Definition: allocator_common.hpp:54
 
rcl_allocator_t get_rcl_allocator(Alloc &allocator)
Definition: allocator_common.hpp:69
 
void(* deallocate)(void *pointer, void *state)
 
#define rcl_get_default_allocator