12#ifndef GMP_META_FIXED_STRING_HPP_
13#define GMP_META_FIXED_STRING_HPP_
35template<std::
size_t N>
55 std::copy_n(
sv.data(), N,
data_);
67 static_assert(
pos <= N,
"fixed_string: index out of range");
90 constexpr operator char const*()
const noexcept {
return data_; }
139 template<auto Pos, auto Count = fixed_
string::npos>
143 static_assert(
Pos <= N,
"fixed_string::substr: position out of range");
144 static_assert(
Pos +
actual_count <= N,
"fixed_string::substr: count out of range");
157template<std::
size_t N>
174template<std::
size_t N1, std::
size_t N2>
188template<fixed_
string s>
189consteval auto operator""_fs() {
197template<fixed_
string Value, auto String>
200 if constexpr (
pos ==
decltype(
String)::npos) {
231 if constexpr (
sizeof...(RestValues) > 0) {
consteval fixed_string< N1+N2 > operator+(fixed_string< N1 > const &s1, fixed_string< N2 > const &s2)
Concatenate two fixed strings at compile time.
fixed_string(char const(&)[N]) -> fixed_string< N - 1 >
Deduce fixed_string length from a string literal.
consteval auto remove_all(constant_arg_t< String >)
Remove all occurrences of one or more compile-time substrings.
constexpr constant_arg_t< V > constant_arg
A ready-to-use constant_arg_t<V> object for a compile-time value.
Wrap a compile-time value as a distinct function argument type.
A compile-time string type with fixed length and constexpr operations.
consteval auto substr(constant_arg_t< Pos >, constant_arg_t< Count >=constant_arg< fixed_string::npos >) const noexcept
Extract a compile-time substring.
friend consteval auto operator<=>(fixed_string const &, fixed_string const &)=default
constexpr auto to_string_view() const noexcept
Convert the fixed string to std::string_view.
consteval const char * data() const noexcept
Get a pointer to the underlying null-terminated character data.
static constexpr size_type npos
consteval size_type length() const noexcept
Get the number of stored characters.
consteval size_type find(const char *str, size_type pos=0) const noexcept
Modifiers.
consteval bool empty() const noexcept
Check whether the fixed string is empty.
constexpr fixed_string(std::string_view sv)
Construct a fixed string from a string view of matching length.
consteval char operator[](size_type pos) const noexcept
Element access.
consteval size_type size() const noexcept
Capacity.
constexpr fixed_string(const char(&str)[N+1])
Construct a fixed string from a string literal.