Template Struct fixed_string

Struct Documentation

template<size_t MAX_CHARS>
struct fixed_string

Template class for non-alloc strings. Will be truncated when assigned from a longer string.

Template Parameters

MAX_CHARS – Maximum number of characters is specified as the template parameter. Space for an additional null terminator will be reserved.

Public Functions

inline fixed_string() noexcept

Default constructor.

inline fixed_string(const char *c_array, size_t n_chars) noexcept
inline fixed_string &assign(const char *c_array, size_t n_chars) noexcept
inline fixed_string(const char *c_string) noexcept
inline fixed_string &operator=(const char *c_string) noexcept
inline fixed_string(const std::string &str) noexcept
inline fixed_string &operator=(const std::string &str) noexcept
template<size_t N>
inline fixed_string &operator=(const fixed_string<N> &rhs) noexcept
inline const char *c_str() const noexcept
inline std::string to_string() const
inline bool operator==(const char *rhs) const noexcept
inline bool operator==(const std::string &rhs) const noexcept
template<size_t N>
inline bool operator==(const fixed_string<N> &rhs) const noexcept
inline bool operator!=(const char *rhs) const noexcept
inline bool operator!=(const std::string &rhs) const noexcept
template<size_t N>
inline bool operator!=(const fixed_string<N> &rhs) const noexcept
inline operator const char*() const noexcept
inline size_t size() const noexcept
inline int compare(const char *str) const noexcept

Compare with a C string.

Parameters

str – C string to be compared with.

Returns

Integer value with the result of the comparison as described in std::string::compare().

inline int compare(const std::string &str) const noexcept

Compare with a std::string.

Parameters

str – std::string to be compared with.

Returns

Integer value with the result of the comparison as described in std::string::compare().

template<size_t N>
inline int compare(const fixed_string<N> &str) const noexcept

Compare with a fixed_string

Parameters

strfixed_string to be compared with.

Returns

Integer value with the result of the comparison as described in std::string::compare().

Public Static Attributes

static constexpr size_t max_size = MAX_CHARS