template<class... Args>
class toy::FormatString< Args >
Wrapper around a toy::CStringView pattern with consteval validation of placeholders.
Two modes are supported, not mixed in one pattern: auto-indexed placeholders are exactly {}; positional placeholders are {0}, {1}, … (decimal digits only). {{ and }} are literal braces. In auto mode the number of {} must equal sizeof...(Args). In positional mode each index must be < sizeof...(Args); repeating an index is allowed and not every index need appear. Unmatched { or } makes construction ill-formed.
- Template Parameters
-
| Args | Template parameter pack representing the types of arguments that will be formatted. |
Key Features
- Compile-time checks:
consteval constructor; invalid patterns fail at compile time.
- Auto and positional modes:
{} vs {N}; mixing both in one string is ill-formed.
- Storage: Holds a toy::CStringView to the pattern; no allocation.
- get(): Returns the same view;
constexpr noexcept.
Usage Example
Non-owning string view class for C-style strings.
Definition c_string_view.hpp:109
Umbrella header for the engine core module.
Performance Characteristics
- Construction: Work is done at compile time (
consteval).
- get(): O(1); returns the stored toy::CStringView.
Safety Guarantees
- Invalid patterns: Diagnosed at compile time when the
consteval constructor runs.
- Exception safety: All operations are
noexcept; this type does not throw.
Compatibility
- See also
- CStringView