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

String expression that substitutes the values ​​of the passed string expressions into the specified positions in the pattern string, specified at runtime. More...

#include <strexpr.h>

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

Public Member Functions

constexpr e_vsubst (str_src< K > pattern, Args &&...args)
 Creates a string expression that substitutes the values ​​of the passed string expressions into the specified positions in the pattern string, specified at runtime.
 

Detailed Description

template<typename K, typename ... Args>
struct simstr::e_vsubst< K, Args >

String expression that substitutes the values ​​of the passed string expressions into the specified positions in the pattern string, specified at runtime.

Constructor & Destructor Documentation

◆ e_vsubst()

template<typename K, typename ... Args>
simstr::e_vsubst< K, Args >::e_vsubst ( str_src< K > pattern,
Args &&... args )
inlineconstexpr

Creates a string expression that substitutes the values ​​of the passed string expressions into the specified positions in the pattern string, specified at runtime.

Parameters
pattern- the pattern string object into which the values ​​of the passed arguments will be substituted.
args...- the arguments to be substituted into the specified positions in the pattern. As in e_concat, these can be string literals, string expressions, standard strings, and any types that can be converted to string expressions.

The function creates a string expression that, when materialized, generates text from the pattern, substituting the values ​​of the passed arguments into the substitution positions. The pattern string is specified at runtime by a string object that is parsed at runtime. Insertion points are designated either as {} or {number}. If no number is specified, parameters are substituted in the order passed to the function. If a number is specified, parameters are substituted according to the specified ordinal number. Parameter numbering starts with 1. You cannot mix parameters with and without numbers; only one of the options is used for all substitutions. If numbers are specified, one parameter can participate in multiple substitutions. All passed parameters must participate in substitutions. If a string parsing error occurs, a parse_subst_string_error exception will be thrown. To insert the curly braces themselves, they must be doubled - {{, }}. This function is not a replacement for std::vformat, does not work with the pattern specified at compile-time, 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:

std::string_view pattern;
.....
lstringa<100> text = e_vsubst(pattern, from, total, success ? "success"_ss : "fail"_ss);
constexpr e_vsubst(str_src< K > pattern, Args &&...args)
Creates a string expression that substitutes the values ​​of the passed string expressions into the s...
Definition strexpr.h:6800

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