forked from mpusz/mp-units
feat: .view()
member funciton added to fixed_string
This commit is contained in:
@@ -85,6 +85,11 @@ struct basic_fixed_string {
|
||||
[[nodiscard]] constexpr const_iterator end() const noexcept { return data() + size(); }
|
||||
[[nodiscard]] constexpr const_iterator cend() const noexcept { return data() + size(); }
|
||||
|
||||
[[nodiscard]] constexpr std::basic_string_view<CharT> view() const noexcept
|
||||
{
|
||||
return std::basic_string_view<CharT>(*this);
|
||||
}
|
||||
|
||||
template<std::size_t N2>
|
||||
[[nodiscard]] constexpr friend basic_fixed_string<CharT, N + N2> operator+(
|
||||
const basic_fixed_string& lhs, const basic_fixed_string<CharT, N2>& rhs) noexcept
|
||||
|
@@ -54,4 +54,8 @@ static_assert(basic_fixed_string('d') + txt2 == basic_fixed_string("dabc"));
|
||||
static_assert(txt2 + basic_fixed_string("def") == basic_fixed_string("abcdef"));
|
||||
static_assert(basic_fixed_string("def") + txt2 == basic_fixed_string("defabc"));
|
||||
|
||||
#ifndef MP_UNITS_COMP_GCC
|
||||
static_assert(basic_fixed_string("abcd").view().find('c') == 2);
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user