0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-28 03:38:53 +02:00

ircd::buffer: Compiler errors when copy source may be string literal.

This commit is contained in:
Jason Volk 2018-02-19 16:47:17 -08:00
parent cede265037
commit c5f4ab4a17

View file

@ -63,6 +63,7 @@ namespace ircd::buffer
template<class it> size_t consume(buffer<it> &buffer, const size_t &bytes);
template<class it> buffer<it> operator+(const buffer<it> &buffer, const size_t &bytes);
template<class it> it copy(it &dest, const it &stop, const const_buffer &);
template<size_t SIZE> size_t copy(const mutable_buffer &dst, const char (&buf)[SIZE]);
size_t copy(const mutable_buffer &dst, const const_buffer &src);
size_t reverse(const mutable_buffer &dst, const const_buffer &src);
void reverse(const mutable_buffer &buf);
@ -535,6 +536,19 @@ ircd::buffer::reverse(const mutable_buffer &dst,
return ret;
}
template<size_t SIZE>
__attribute__((error
(
"Copy source is an array. Is this a string literal? Do you want to copy the \\0?"
" Disambiguate this by typing the source string_view or const_buffer."
)))
inline size_t
ircd::buffer::copy(const mutable_buffer &dst,
const char (&buf)[SIZE])
{
return copy(dst, const_buffer{buf});
}
inline size_t
ircd::buffer::copy(const mutable_buffer &dst,
const const_buffer &src)