diff options
author | Max Kellermann <max@musicpd.org> | 2017-04-12 13:09:11 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-07-05 12:09:27 +0200 |
commit | 9237f2a80c3549fdc473b2ff08b2457204760180 (patch) | |
tree | d6e5d2f27044f0051909e4c4d2b5482ea497b532 | |
parent | 61aca389c467a3fe38cd51144f2fba0e7cf78ec9 (diff) |
util/{Const,Writable}Buffer: add array constructor
-rw-r--r-- | src/util/ConstBuffer.hxx | 7 | ||||
-rw-r--r-- | src/util/WritableBuffer.hxx | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/util/ConstBuffer.hxx b/src/util/ConstBuffer.hxx index d71088588..cea0bddf8 100644 --- a/src/util/ConstBuffer.hxx +++ b/src/util/ConstBuffer.hxx @@ -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); } diff --git a/src/util/WritableBuffer.hxx b/src/util/WritableBuffer.hxx index 2782fecf1..fc3b872ab 100644 --- a/src/util/WritableBuffer.hxx +++ b/src/util/WritableBuffer.hxx @@ -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 }; } |