diff --git a/include/cppkafka/buffer.h b/include/cppkafka/buffer.h index afa61b5a..1c5e7c92 100644 --- a/include/cppkafka/buffer.h +++ b/include/cppkafka/buffer.h @@ -96,6 +96,21 @@ class CPPKAFKA_API Buffer { template Buffer(std::vector&& data) = delete; + /** + * Constructs a buffer from an array + * + * \param data The the array to be used as input + */ + template + Buffer(const std::array& data) + : data_(reinterpret_cast(data.data())), size_(data.size()) { + static_assert(sizeof(T) == sizeof(DataType), "sizeof(T) != sizeof(DataType)"); + } + + // Don't allow construction from temporary arrays + template + Buffer(std::array&& data) = delete; + /** * \brief Construct a buffer from a const string ref *