simstr 1.7.3
Yet another strings library
 
Loading...
Searching...
No Matches
simstr::e_subst< K, PtLen, Args > Struct Template Reference

String expression that substitutes the values ​​of the passed string expressions into the specified places in a string literal. More...

#include <strexpr.h>

Inheritance diagram for simstr::e_subst< K, PtLen, Args >:
simstr::expr_to_std_string< e_subst< K, PtLen, Args... > >

Public Member Functions

constexpr e_subst (const details::subst_params< K, PtLen, NParams > &subst, Args &&...args)
 Creates a string expression that substitutes the values ​​of the passed string expressions into the specified places in a string literal.
 

Detailed Description

template<typename K, size_t PtLen, typename ... Args>
struct simstr::e_subst< K, PtLen, Args >

String expression that substitutes the values ​​of the passed string expressions into the specified places in a string literal.

Constructor & Destructor Documentation

◆ e_subst()

template<typename K, size_t PtLen, typename ... Args>
simstr::e_subst< K, PtLen, Args >::e_subst ( const details::subst_params< K, PtLen, NParams > & subst,
Args &&... args )
inlineconstexpr

Creates a string expression that substitutes the values ​​of the passed string expressions into the specified places in a string literal.

Parameters
pattern- information parsed during compilation in the template string, containing the lengths of text chunks and places to insert parameters. Created automatically from the passed string literal.
args...- arguments that will be inserted into the specified places in the sample. Also, as in e_concat, there can be string literals, string expressions, standard strings, as well as any types for which there is a conversion to a string expression.

The function creates a string expression, which, when materialized, generates text from the sample, substituting it in placeholders values ​​of the passed arguments. The pattern string is specified by a string literal, a compile-time constant. Insertion locations are indicated by either {} or {number}. In case without spectacle number, the parameters are submitted to the order of order. In case of the index number, the parameters are submitted in accordance with with the specified serial number. The numbering of parameters starts from 1. You cannot mix parameters without a number and with a number - only used one of the options for all substitutions. In the case of specifying numbers, one parameter can participate in several substitutions. All passed parameters must participate in substitutions. To insert curly braces themselves, they must be doubled - {{, }}. The sample string is processed during compilation, and an array is immediately created for it with information about insertions - which parts of the string to copy in the result, where to insert the passed values. The function is not a replacement for std::format, does not work with the sample specified at runtime, and does not support any formatting options for substituted values. All passed arguments must be able to convert themselves to string expressions (see Converting types to string expressions). Example:

lstringu<100> u16t = e_subst(u"Test {} from {}, {}.", from, total, success ? u"success"_ss : u"fail"_ss);
constexpr e_subst(const details::subst_params< K, PtLen, NParams > &subst, Args &&...args)
Creates a string expression that substitutes the values ​​of the passed string expressions into the s...
Definition strexpr.h:6701

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