0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 16:22:35 +01:00

ircd: Allow restricted pointer constructions for string_view/vector_view.

This commit is contained in:
Jason Volk 2021-03-15 18:39:03 -07:00
parent 0cef0848e1
commit 90f88cf78d
2 changed files with 8 additions and 8 deletions

View file

@ -118,7 +118,7 @@ struct ircd::string_view
}
// (non-standard) our iterator-based assign
string_view &assign(const char *const &begin, const char *const &end)
string_view &assign(const char *const &__restrict__ begin, const char *const &__restrict__ end)
{
this->~string_view();
new (this) string_view{begin, end};
@ -152,7 +152,7 @@ struct ircd::string_view
}
// (non-standard) our iterator-based constructor
constexpr string_view(const char *const &begin, const char *const &end) noexcept
constexpr string_view(const char *const &__restrict__ begin, const char *const &__restrict__ end) noexcept
:string_view{begin, size_t(end - begin)}
{
assert(begin <= end);
@ -175,17 +175,17 @@ struct ircd::string_view
// (non-standard) our buffer based constructor
template<size_t SIZE> constexpr
__attribute__((always_inline))
string_view(const char (&buf)[SIZE]) noexcept
string_view(const char (&__restrict__ buf)[SIZE]) noexcept
:string_view
{
buf, std::find(buf, buf + SIZE, '\0')
}{}
constexpr string_view(const char *const &start, const size_t &size) noexcept
constexpr string_view(const char *const &__restrict__ start, const size_t &size) noexcept
:std::string_view{start, size}
{}
constexpr string_view(const char *const &start) noexcept
constexpr string_view(const char *const &__restrict__ start) noexcept
:std::string_view{start, _constexpr_strlen(start)}
{}

View file

@ -75,13 +75,13 @@ struct ircd::vector_view
return at(0);
}
vector_view(const pointer start, const pointer stop)
vector_view(const pointer __restrict__ start, const pointer __restrict__ stop)
noexcept
:_data{start}
,_stop{stop}
{}
vector_view(const pointer start, const size_t size)
vector_view(const pointer __restrict__ start, const size_t size)
noexcept
:vector_view(start, start + size)
{}
@ -111,7 +111,7 @@ struct ircd::vector_view
{}
template<size_t SIZE>
vector_view(value_type (&buffer)[SIZE])
vector_view(value_type (&__restrict__ buffer)[SIZE])
noexcept
:vector_view(buffer, SIZE)
{}