Shows how to use xtd::expressions::expression::add expression.
#include <xtd/xtd>
struct foo {
int value;
auto operator +(const foo& v) -> foo {return foo {value + v.value};}
};
auto main() -> int {
auto add = _1 + _2;
println(R"(add(40, 20)) = {})", add(40, 20));
println(R"(add("Barry "_s, "Allen"_s) = {})", add("Barry "_s, "Allen"_s));
println(R"(add(date_time {2026, 4, 20, 21, 12, 36}, 7_min + 24_s) = {})", add(date_time {2026, 4, 20, 21, 12, 36}, 7_min + 24_s));
println(R"(add(foo {{50}}, foo {{30}}) = {})", add(foo {50}, foo {30}).value);
}
@ add
The Add key.
Definition console_key.hpp:170
auto println(FILE *file) -> void
Writes the current line terminator to the file output stream using the specified format information.
Definition println.hpp:15