Merge pull request #138 from tgaldes/master

Add support for constructing Buffer from std::array
This commit is contained in:
Matias Fontanini
2018-11-19 16:58:34 -08:00
committed by GitHub

View File

@@ -96,6 +96,21 @@ public:
template <typename T>
Buffer(std::vector<T>&& data) = delete;
/**
* 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.data())), size_(data.size()) {
static_assert(sizeof(T) == sizeof(DataType), "sizeof(T) != sizeof(DataType)");
}
// Don't allow construction from temporary arrays
template <typename T, size_t N>
Buffer(std::array<T, N>&& data) = delete;
/**
* \brief Construct a buffer from a const string ref
*