util/{Const,Writable}Buffer: add array constructor

This commit is contained in:
Max Kellermann 2017-04-12 13:09:11 +02:00
parent 61aca389c4
commit 9237f2a80c
2 changed files with 14 additions and 0 deletions

View File

@ -105,6 +105,13 @@ struct ConstBuffer {
constexpr ConstBuffer(pointer_type _data, size_type _size)
:data(_data), size(_size) {}
/**
* Convert array to ConstBuffer instance.
*/
template<size_type _size>
constexpr ConstBuffer(const T (&_data)[_size])
:data(_data), size(_size) {}
constexpr static ConstBuffer Null() {
return ConstBuffer(nullptr, 0);
}

View File

@ -99,6 +99,13 @@ struct WritableBuffer {
constexpr WritableBuffer(pointer_type _data, size_type _size)
:data(_data), size(_size) {}
/**
* Convert array to WritableBuffer instance.
*/
template<size_type _size>
constexpr WritableBuffer(T (&_data)[_size])
:data(_data), size(_size) {}
constexpr static WritableBuffer Null() {
return { nullptr, 0 };
}