diff --git a/rclcpp/include/rclcpp/experimental/buffers/ring_buffer_implementation.hpp b/rclcpp/include/rclcpp/experimental/buffers/ring_buffer_implementation.hpp index 3036a5eeb4..e22397f30c 100644 --- a/rclcpp/include/rclcpp/experimental/buffers/ring_buffer_implementation.hpp +++ b/rclcpp/include/rclcpp/experimental/buffers/ring_buffer_implementation.hpp @@ -244,7 +244,11 @@ class RingBufferImplementation : public BufferImplementationBase * * \return a vector containing all the elements from the ring buffer */ - template::value, void> * = nullptr> + template::value && + std::is_copy_constructible< + typename is_std_unique_ptr::Ptr_type + >::value, + void> * = nullptr> std::vector get_all_data_impl() { std::lock_guard lock(mutex_); @@ -258,7 +262,8 @@ class RingBufferImplementation : public BufferImplementationBase return result_vtr; } - template::value, void> * = nullptr> + template::value, void> * = nullptr> std::vector get_all_data_impl() { std::lock_guard lock(mutex_); @@ -270,6 +275,23 @@ class RingBufferImplementation : public BufferImplementationBase return result_vtr; } + template::value && + !std::is_copy_constructible::value, void> * = nullptr> + std::vector get_all_data_impl() + { + throw std::logic_error("Underlined type results in invalid get_all_data_impl()"); + return {}; + } + + template::value && + !std::is_copy_constructible::Ptr_type>::value, + void> * = nullptr> + std::vector get_all_data_impl() + { + throw std::logic_error("Underlined type in unique_ptr results in invalid get_all_data_impl()"); + return {}; + } + size_t capacity_; std::vector ring_buffer_;