mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-11-02 11:37:50 +00:00
Add support for constructing Buffer from std::array
This commit is contained in:
@@ -92,6 +92,17 @@ public:
|
|||||||
static_assert(sizeof(T) == sizeof(DataType), "sizeof(T) != sizeof(DataType)");
|
static_assert(sizeof(T) == sizeof(DataType), "sizeof(T) != sizeof(DataType)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a buffer from an array
|
||||||
|
*
|
||||||
|
* \param data The the array to be used as input
|
||||||
|
*/
|
||||||
|
template <typename T, size_t N>
|
||||||
|
Buffer(const std::array<T, N>& data)
|
||||||
|
: data_(reinterpret_cast<const DataType*>(&data[0])), size_(N * sizeof(T)) {
|
||||||
|
static_assert(sizeof(T) == sizeof(DataType), "sizeof(T) != sizeof(DataType)");
|
||||||
|
}
|
||||||
|
|
||||||
// Don't allow construction from temporary vectors
|
// Don't allow construction from temporary vectors
|
||||||
template <typename T>
|
template <typename T>
|
||||||
Buffer(std::vector<T>&& data) = delete;
|
Buffer(std::vector<T>&& data) = delete;
|
||||||
|
|||||||
Reference in New Issue
Block a user