mirror of
				https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
				synced 2025-10-31 18:47:48 +00:00 
			
		
		
		
	Allow constructing Buffers from std::vector
This commit is contained in:
		| @@ -77,6 +77,21 @@ public: | ||||
|         static_assert(sizeof(T) == sizeof(DataType), "sizeof(T) != sizeof(DataType)"); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Constructs a buffer from a vector | ||||
|      * | ||||
|      * \param data The vector to be used as input | ||||
|      */ | ||||
|     template <typename T> | ||||
|     Buffer(const std::vector<T>& data) | ||||
|     : data_(data.data()), size_(data.size()) { | ||||
|         static_assert(sizeof(T) == sizeof(DataType), "sizeof(T) != sizeof(DataType)"); | ||||
|     } | ||||
|  | ||||
|     // Don't allow construction from temporary vectors | ||||
|     template <typename T> | ||||
|     Buffer(std::vector<T>&& data) = delete; | ||||
|  | ||||
|     /** | ||||
|      * \brief Construct a buffer from a const string ref | ||||
|      * | ||||
| @@ -85,7 +100,7 @@ public: | ||||
|      */ | ||||
|     Buffer(const std::string& data);  | ||||
|  | ||||
|     // Don't allow construction from temporaries | ||||
|     // Don't allow construction from temporary strings | ||||
|     Buffer(std::string&&) = delete; | ||||
|  | ||||
|     Buffer(const Buffer&) = delete; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Matias Fontanini
					Matias Fontanini