morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::detail::FixedString< N > Struct Template Reference

A structural, NTTP-capable compile-time string. More...

#include <fixed_string.hpp>

Public Member Functions

constexpr FixedString (const char(&literal)[N]) noexcept
 Captures a string literal.
constexpr std::string_view view () const noexcept
 A view of the string (without the terminating null).

Public Attributes

std::array< char, N > data {}
 Character storage (null-terminated).

Detailed Description

template<std::size_t N>
struct morph::detail::FixedString< N >

A structural, NTTP-capable compile-time string.

A literal type with public array storage, so it satisfies the rules for a non-type template parameter. Two FixedString values of the same length with the same characters compare equal as template arguments, so a type parameterised on a FixedString written identically in two translation units is one and the same type.

This is the single canonical definition. The forms layer aliases it twice — as morph::forms::FixedString (used by Choice) and as morph::forms::detail::LiteralString (which captures an equals rule literal) — and the units layer once, as morph::units::detail::FixedString (used by NamedQuantity). None of them redefine their own copy.

Template Parameters
NStorage size including the terminating null.

Definition at line 33 of file fixed_string.hpp.

Constructor & Destructor Documentation

◆ FixedString()

template<std::size_t N>
morph::detail::FixedString< N >::FixedString ( const char(&) literal[N])
inlineconstexprnoexcept

Captures a string literal.

constexpr, not consteval: as an NTTP this is still only ever evaluated at compile time (that context demands it regardless), but constexpr additionally lets a function parameter of type const char (&)[N] be captured — morph::forms::equals(&A::code, "X") forwards its literal exactly that way, and a consteval constructor cannot be called with a reference parameter, which is not itself a constant expression.

Parameters
literalThe literal to copy, e.g. "ListSamples".

Definition at line 54 of file fixed_string.hpp.

Member Function Documentation

◆ view()

template<std::size_t N>
std::string_view morph::detail::FixedString< N >::view ( ) const
inlinenodiscardconstexprnoexcept

A view of the string (without the terminating null).

Returns
The string contents.

Definition at line 64 of file fixed_string.hpp.

Member Data Documentation

◆ data

template<std::size_t N>
std::array<char, N> morph::detail::FixedString< N >::data {}

Character storage (null-terminated).

Definition at line 35 of file fixed_string.hpp.


The documentation for this struct was generated from the following file: