Flatstring Functions

#include <xo/flatstring/flatstring.hpp>

Warning

doxygenfunction: Cannot find function “xo::flatstring_concat” in doxygen xml output for project “xodoxxml” from directory: /build/xo-flatstring/build/docs/dox/xml

template<std::size_t N1, std::size_t N2>
auto flatstring_compare(const flatstring<N1> &s1, const flatstring<N2> &s2) noexcept

compare two flatstrings lexicographically.

Example:

constexpr auto cmp = flatstring_compare(flatstring("foo"), flatstring("bar"));
static_assert(cmp > 0);

template<std::size_t N1, std::size_t N2>
auto operator<=>(const flatstring<N1> &s1, const flatstring<N2> &s2) noexcept

3-way compare for two flatstrings

Example

constexpr auto cmp = (flatstring("foo") <=> flatstring("bar"));
static_assert(cmp != 0);

template<std::size_t N1, std::size_t N2>
bool operator==(const flatstring<N1> &s1, const flatstring<N2> &s2) noexcept

equality comparison for two flatstrings.

Example

constexpr bool cmp = (flatstring("foo") == flatstring("foo"));
static_assert(cmp == true);

Note

spaceship operator alone isn’t sufficient to get this defined, at least with gcc 13.1

template<std::size_t N, typename S>
auto operator<=>(const flatstring<N> &s1, const S &s2) noexcept

3-way compare between flatstring and string-like

Example

constexpr auto cmp = (flatstring("foo") <=> "foo");
static_assert(cmp != 0);

template<std::size_t N, typename S>
bool operator==(const flatstring<N> &s1, const S &s2) noexcept

equality comparison between flatstring and string-like

Example

constexpr bool cmp = (flatstring("foo") == "foo");
static_assert(cmp == true);