DiFfRG
Loading...
Searching...
No Matches
fixed_string.hh
Go to the documentation of this file.
1#pragma once
2
3namespace DiFfRG
4{
10 template <unsigned N> struct FixedString {
11 char buf[N + 1]{};
12
19 constexpr FixedString(char const *s)
20 {
21 for (unsigned i = 0; i != N; ++i)
22 buf[i] = s[i];
23 }
24
25 constexpr operator char const *() const { return buf; }
26
27 auto operator<=>(const FixedString &) const = default;
28 };
29
30 template <unsigned N> FixedString(char const (&)[N]) -> FixedString<N - 1>;
31} // namespace DiFfRG
Definition complex_math.hh:14
FixedString(char const (&)[N]) -> FixedString< N - 1 >
A fixed size compile-time string.
Definition fixed_string.hh:10
char buf[N+1]
Definition fixed_string.hh:11
auto operator<=>(const FixedString &) const =default
constexpr FixedString(char const *s)
Construct a new Fixed String object.
Definition fixed_string.hh:19