Shows how to use xtd::expressions::expression::divide expression.
#include <xtd/xtd>
struct foo {
int value;
friend auto operator <<(std::ostream& os, const foo& f) -> std::ostream& {return os << f.value;}
friend auto operator /(const foo& a, const foo& b) -> foo {return foo {a.value / b.value};}
};
auto main() -> int {
auto expr1 = _ / 2;
println("expr1 = {}", expr1(84));
println();
auto expr2 = _1 / _2;
println("expr2 = {}", expr2(84, 2));
println("expr2 = {}", expr2(foo {84}, foo {2}));
auto expr3 =
_1 / 2 /
_2 /
_3;
println(
"expr3 = {}", expr3(84, 7, 3));
}
constexpr auto _2
The xtd::expressions::_2 arg instance is second argument used by expression.
Definition args.hpp:119
constexpr auto _3
The xtd::expressions::_3 arg instance is third argument used by expression.
Definition args.hpp:144
constexpr auto _1
The xtd::expressions::_1 arg instance is first argument used by expression.
Definition args.hpp:94
auto println(FILE *file) -> void
Writes the current line terminator to the file output stream using the specified format information.
Definition println.hpp:15