mirror of
https://github.com/matrix-construct/construct
synced 2024-11-16 06:51:08 +01:00
ircd::buffer: Compiler errors when copy source may be string literal.
This commit is contained in:
parent
cede265037
commit
c5f4ab4a17
1 changed files with 14 additions and 0 deletions
|
@ -63,6 +63,7 @@ namespace ircd::buffer
|
||||||
template<class it> size_t consume(buffer<it> &buffer, const size_t &bytes);
|
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> 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<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 copy(const mutable_buffer &dst, const const_buffer &src);
|
||||||
size_t reverse(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);
|
void reverse(const mutable_buffer &buf);
|
||||||
|
@ -535,6 +536,19 @@ ircd::buffer::reverse(const mutable_buffer &dst,
|
||||||
return ret;
|
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
|
inline size_t
|
||||||
ircd::buffer::copy(const mutable_buffer &dst,
|
ircd::buffer::copy(const mutable_buffer &dst,
|
||||||
const const_buffer &src)
|
const const_buffer &src)
|
||||||
|
|
Loading…
Reference in a new issue