Go to the documentation of this file.
22 #ifndef FIXED_STRING_H
23 #define FIXED_STRING_H
26 #include <string_view>
28 template<std::
size_t N>
35 for(
unsigned i = 0; i != N; ++i)
45 static_assert(N==T::Length,
"String mismatch");
54 constexpr
operator auto()
const
60 constexpr
operator int()
const
63 constexpr
operator std::string_view()
const
64 {
return std::string_view(
m_data); }
66 constexpr
operator std::string()
const
67 {
return std::string(
m_data); }
69 constexpr
const char *
data()
const
72 template<std::
size_t M>
73 constexpr
bool compare(
const char(&other)[M])
const
75 const auto l = N<M ? N : M;
76 for(std::size_t i = 0; i < l; ++i)
78 const auto cmp = other[i] -
m_data[i];
103 {
return this->
compare(str.data()); }
106 template<std::
size_t N>
109 template<std::
size_t N>
117 #endif // FIXED_STRING_H
static constexpr auto Length
Definition: fixed_string.h:31
constexpr bool compare(const char(&other)[M]) const
Definition: fixed_string.h:73
constexpr const char * data() const
Definition: fixed_string.h:69
constexpr FixedString(const char(&str)[N])
Definition: fixed_string.h:33
constexpr FixedString()
Definition: fixed_string.h:48
constexpr bool compare(const std::string_view &str) const
Definition: fixed_string.h:102
constexpr FixedString(T str)
Definition: fixed_string.h:42
Definition: fixed_string.h:29
str
Definition: python_grpc_engine.py:63
constexpr bool compare(const char *const str) const
Definition: fixed_string.h:86
char m_data[N]
Definition: fixed_string.h:53
FixedString(const char(&str)[N]) -> FixedString< N >