}
constexpr basic_string_view(const basic_string_view &) noexcept = default;
template <typename Allocator>
- constexpr basic_string_view(
- const std::basic_string<Char_type, Traits_type, Allocator> &str) noexcept
+ basic_string_view(const std::basic_string<Char_type, Traits_type, Allocator> &str) noexcept
: string_pointer(str.data()),
string_size(str.size())
{
string_size(count)
{
}
- basic_string_view(const Char_type *str)
+ constexpr basic_string_view(const Char_type *str)
: string_pointer(str), string_size(traits_type::length(str))
{
}
- basic_string_view &operator=(const basic_string_view &) noexcept = default;
+ constexpr basic_string_view &operator=(const basic_string_view &) noexcept = default;
constexpr const_iterator begin() const noexcept
{
return string_pointer;
{
return string_size == 0;
}
- void remove_prefix(std::size_t n) noexcept
+ constexpr void remove_prefix(std::size_t n) noexcept
{
string_pointer += n;
string_size -= n;
}
- void remove_suffix(std::size_t n) noexcept
+ constexpr void remove_suffix(std::size_t n) noexcept
{
string_size -= n;
}
- void swap(basic_string_view &rt) noexcept
+ constexpr void swap(basic_string_view &rt) noexcept
{
basic_string_view temp = *this;
*this = rt;
rt = temp;
}
- std::size_t copy(Char_type *dest, std::size_t count, std::size_t pos = 0) const
+ constexpr std::size_t copy(Char_type *dest, std::size_t count, std::size_t pos = 0) const
{
if(pos > count)
throw std::out_of_range("out of range in util::basic_string_view::copy");
{
return substr(pos1, count1).compare(basic_string_view(rt, count2));
}
- std::size_t find(basic_string_view v, std::size_t pos = 0) const noexcept
+ constexpr std::size_t find(basic_string_view v, std::size_t pos = 0) const noexcept
{
if(pos > string_size)
return npos;
}
return npos;
}
- std::size_t find(Char_type c, std::size_t pos = 0) const noexcept
+ constexpr std::size_t find(Char_type c, std::size_t pos = 0) const noexcept
{
return find(basic_string_view(std::addressof(c), 1), pos);
}
- std::size_t find(const Char_type *s, std::size_t pos, std::size_t count) const noexcept
+ constexpr std::size_t find(const Char_type *s, std::size_t pos, std::size_t count) const
+ noexcept
{
return find(basic_string_view(s, count), pos);
}
- std::size_t find(const Char_type *s, std::size_t pos = 0) const
+ constexpr std::size_t find(const Char_type *s, std::size_t pos = 0) const
{
return find(basic_string_view(s), pos);
}
- std::size_t rfind(basic_string_view v, std::size_t pos = npos) const noexcept
+ constexpr std::size_t rfind(basic_string_view v, std::size_t pos = npos) const noexcept
{
if(v.string_size > string_size)
return npos;
}
return npos;
}
- std::size_t rfind(Char_type c, std::size_t pos = npos) const noexcept
+ constexpr std::size_t rfind(Char_type c, std::size_t pos = npos) const noexcept
{
return rfind(basic_string_view(std::addressof(c), 1), pos);
}
- std::size_t rfind(const Char_type *s, std::size_t pos, std::size_t count) const noexcept
+ constexpr std::size_t rfind(const Char_type *s, std::size_t pos, std::size_t count) const
+ noexcept
{
return rfind(basic_string_view(s, count), pos);
}
- std::size_t rfind(const Char_type *s, std::size_t pos = npos) const
+ constexpr std::size_t rfind(const Char_type *s, std::size_t pos = npos) const
{
return rfind(basic_string_view(s), pos);
}
- std::size_t find_first_of(basic_string_view v, std::size_t pos = 0) const noexcept
+ constexpr std::size_t find_first_of(basic_string_view v, std::size_t pos = 0) const noexcept
{
for(; pos < string_size; pos++)
{
}
return npos;
}
- std::size_t find_first_of(Char_type v, std::size_t pos = 0) const noexcept
+ constexpr std::size_t find_first_of(Char_type v, std::size_t pos = 0) const noexcept
{
return find(v, pos);
}
- std::size_t find_first_of(const Char_type *s, std::size_t pos, std::size_t count) const noexcept
+ constexpr std::size_t find_first_of(const Char_type *s,
+ std::size_t pos,
+ std::size_t count) const noexcept
{
return find_first_of(basic_string_view(s, count), pos);
}
- std::size_t find_first_of(const Char_type *s, std::size_t pos = 0) const
+ constexpr std::size_t find_first_of(const Char_type *s, std::size_t pos = 0) const
{
return find_first_of(basic_string_view(s), pos);
}
- std::size_t find_first_not_of(basic_string_view v, std::size_t pos = 0) const noexcept
+ constexpr std::size_t find_first_not_of(basic_string_view v, std::size_t pos = 0) const noexcept
{
for(; pos < string_size; pos++)
{
}
return npos;
}
- std::size_t find_first_not_of(Char_type v, std::size_t pos = 0) const noexcept
+ constexpr std::size_t find_first_not_of(Char_type v, std::size_t pos = 0) const noexcept
{
return find_first_not_of(basic_string_view(std::addressof(v), 1), pos);
}
- std::size_t find_first_not_of(const Char_type *s, std::size_t pos, std::size_t count) const
- noexcept
+ constexpr std::size_t find_first_not_of(const Char_type *s,
+ std::size_t pos,
+ std::size_t count) const noexcept
{
return find_first_not_of(basic_string_view(s, count), pos);
}
- std::size_t find_first_not_of(const Char_type *s, std::size_t pos = 0) const
+ constexpr std::size_t find_first_not_of(const Char_type *s, std::size_t pos = 0) const
{
return find_first_not_of(basic_string_view(s), pos);
}
- std::size_t find_last_of(basic_string_view v, std::size_t pos = npos) const noexcept
+ constexpr std::size_t find_last_of(basic_string_view v, std::size_t pos = npos) const noexcept
{
if(empty())
return npos;
}
return npos;
}
- std::size_t find_last_of(Char_type v, std::size_t pos = npos) const noexcept
+ constexpr std::size_t find_last_of(Char_type v, std::size_t pos = npos) const noexcept
{
return rfind(v, pos);
}
- std::size_t find_last_of(const Char_type *s, std::size_t pos, std::size_t count) const noexcept
+ constexpr std::size_t find_last_of(const Char_type *s, std::size_t pos, std::size_t count) const
+ noexcept
{
return find_last_of(basic_string_view(s, count), pos);
}
- std::size_t find_last_of(const Char_type *s, std::size_t pos = npos) const
+ constexpr std::size_t find_last_of(const Char_type *s, std::size_t pos = npos) const
{
return find_last_of(basic_string_view(s), pos);
}
- std::size_t find_last_not_of(basic_string_view v, std::size_t pos = npos) const noexcept
+ constexpr std::size_t find_last_not_of(basic_string_view v, std::size_t pos = npos) const
+ noexcept
{
if(empty())
return npos;
}
return npos;
}
- std::size_t find_last_not_of(Char_type v, std::size_t pos = npos) const noexcept
+ constexpr std::size_t find_last_not_of(Char_type v, std::size_t pos = npos) const noexcept
{
return find_last_not_of(basic_string_view(std::addressof(v), 1), pos);
}
- std::size_t find_last_not_of(const Char_type *s, std::size_t pos, std::size_t count) const
- noexcept
+ constexpr std::size_t find_last_not_of(const Char_type *s,
+ std::size_t pos,
+ std::size_t count) const noexcept
{
return find_last_not_of(basic_string_view(s, count), pos);
}
- std::size_t find_last_not_of(const Char_type *s, std::size_t pos = npos) const
+ constexpr std::size_t find_last_not_of(const Char_type *s, std::size_t pos = npos) const
{
return find_last_not_of(basic_string_view(s), pos);
}
};
}
-#endif /* UTIL_STRING_VIEW_H_ */
\ No newline at end of file
+#endif /* UTIL_STRING_VIEW_H_ */