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