simstr 1.2.4
Yet another strings library
 
Loading...
Searching...
No Matches
simstr::expr_choice_one_lit< A, N, Compare > Struct Template Reference

Conditional selection string expression. More...

#include <strexpr.h>

Detailed Description

template<StrExpr A, size_t N, bool Compare>
struct simstr::expr_choice_one_lit< A, N, Compare >

Conditional selection string expression.

Template Parameters
ABranch type for true.

An expression that, depending on the truth of the condition, generates either expression A or a string from a string literal. The type is usually not used directly; it is created via e_choice().

Since string literals are not string expressions, use them as a single expression in parts e_choice or e_if would require them to be surrounded by some constructs that convert them to a string expression. You would have to write something like this:

e_choice(condition, text, e_t("empty"));
e_choice(condition, text, eea + "empty");
e_choice(condition, text, "empty"_ss);
e_if(!condition, "empty"_ss);
constexpr auto e_t(T &&s)
Converts a string literal to a string expression.
Definition strexpr.h:655
constexpr auto e_choice(bool c, const A &a, const B &b)
Create a conditional string expression expr_choice.
Definition strexpr.h:1037
constexpr auto e_if(bool c, const A &a)
Creating a conditional string expression expr_if.
Definition strexpr.h:1113
constexpr empty_expr< u8s > eea
Empty string expression of type char.
Definition strexpr.h:522

This, on the one hand, clutters up the code, on the other, makes it less optimal. These overloads use expr_choice_one_lit and expr_choice_two_lit, allowing you to write like this:

e_choice(condition, text, "empty");
e_choice(condition, "false", "true");
e_if(!condition, "empty");

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