xtd 1.0.0
Loading...
Searching...
No Matches
xtd::expressions::expression Struct Reference
Inheritance diagram for xtd::expressions::expression:
xtd::expressions::argument_expression xtd::expressions::binary_expression xtd::expressions::conditional_expression xtd::expressions::invocation_expression xtd::expressions::member_expression< expression_t, member_t > xtd::expressions::unary_expression xtd::expressions::value_expression xtd::expressions::argument< xtd::index > xtd::expressions::argument< index > xtd::expressions::add< left_t, right_t > xtd::expressions::and_< left_t, right_t > xtd::expressions::compare_three_way< left_t, right_t > xtd::expressions::divide< left_t, right_t > xtd::expressions::equal< left_t, right_t > xtd::expressions::greater_than< left_t, right_t > xtd::expressions::greater_than_or_equal< left_t, right_t > xtd::expressions::left_shift< left_t, right_t > xtd::expressions::less_than< left_t, right_t > xtd::expressions::less_than_or_equal< left_t, right_t > xtd::expressions::logical_and< left_t, right_t > xtd::expressions::logical_or< left_t, right_t > xtd::expressions::modulo< left_t, right_t > xtd::expressions::multiply< left_t, right_t > xtd::expressions::not_equal< left_t, right_t > xtd::expressions::or_< left_t, right_t > xtd::expressions::right_shift< left_t, right_t > xtd::expressions::subtract_expression< left_t, right_t > xtd::expressions::xor_< left_t, right_t > xtd::expressions::if_then_else_expression< condition_t, then_t, else_t > xtd::expressions::method_call_expression< expression_t, method_t > xtd::expressions::logical_not< value_t > xtd::expressions::not_< value_t > xtd::expressions::unary_minus_expression< value_t > xtd::expressions::unary_plus_expression< value_t > xtd::expressions::constant< constant_value > xtd::expressions::value< type_t >

Definition

Provides the base class from which the classes that represent expression tree nodes are derived. It also contains static factory methods to create the various node types. This is an abstract class.

Namespace
xtd::expressions
Header
#include <xtd/expressions/expression>
Library
xtd.core
Remarks
The following tables show the expressions by type :
Arithmetic operator
xtd::expressions::expression::add a + b
xtd::expressions::expression::subtract a - b
xtd::expressions::expression::unary_plus +a
xtd::expressions::expression::unary_minus
xtd::expressions::expression::negate
-a
xtd::expressions::expression::multiply a * b
xtd::expressions::expression::divide a / b
xtd::expressions::expression::modulo a % b
Relational operator
xtd::expressions::expression::equal a == b
xtd::expressions::expression::not_equal a != b
xtd::expressions::expression::greater_than a > b
xtd::expressions::expression::less_than a < b
xtd::expressions::expression::greater_than_or_equal a >= b
xtd::expressions::expression::less_than_or_equal a <= b
xtd::expressions::expression::compare_three_way
xtd::expressions::expression::spaceship
a <=> b
Logical operator
xtd::expressions::expression::logical_not !a
xtd::expressions::expression::logical_and
xtd::expressions::expression::and_also
a && b
xtd::expressions::expression::logical_or
xtd::expressions::expression::or_else
a || b
Bitwise operator
xtd::expressions::expression::not_ ~a
xtd::expressions::expression::and_ a & b
xtd::expressions::expression::or_ a | b
xtd::expressions::expression::exclusive_or
xtd::expressions::expression::xor_
a ^ b
xtd::expressions::expression::left_shift a << b
xtd::expressions::expression::right_shift a >> b
Member and pointer operator
xtd::expressions::expression::member
xtd::expressions::expression::method
Conditional operator
xtd::expressions::expression::if_then_else a ? b : c
Others operator
xtd::expressions::expression::constant
xtd::expressions::expression::value
xtd::expressions::expression::arg
Examples
The following example shows how to use xtd::expressions::expression class.
#include <xtd/xtd>
auto main() -> int {
auto value = 30;
// auto expr1 = [value](auto&& _1, auto&& _2) {return (_1 + _2);};
auto expr1 = (_1 + _2) * value;
println("expr1 = {}", expr1(10, 20));
println("expr1 => {}", expr1);
println("type_of(expr1) => {}", type_of(expr1));
// auto expr2 = [value](auto&& _1, auto&& _2) {return (_1 + _2) * value;};
println("expr2 = {}", expr2(10, 20));
println("expr2 => {}", expr2);
println("type_of(expr2) => {}", type_of(expr2));
}
// This code produces the following output :
//
// expr1 = 900
// expr1 => (_1 + _2) * 30
// type_of(expr1) => xtd::expressions::multiply<xtd::expressions::add<xtd::expressions::argument<1ul>, xtd::expressions::argument<2ul>>, xtd::expressions::value<int>>
//
// expr2 = 900
// expr2 => (_1 + _2) * 30
// type_of(expr2) => xtd::expressions::multiply<xtd::expressions::add<xtd::expressions::argument<1ul>, xtd::expressions::argument<2ul>>, xtd::expressions::value<int>>
constexpr auto _2
The xtd::expressions::_2 arg instance is second argument used by expression.
Definition args.hpp:119
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
static constexpr auto add(left_t left, right_t right)
Add the specified left and right operands.
static constexpr auto value(type_t value)
Gets the value value.
static constexpr auto multiply(left_t left, right_t right)
Multiply the specified left and right operands.

Public Static Fields

template<size_t index>
static const xtd::expressions::argument< indexarg
 Gets the index argument used by expression.

Public Static Methods

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto add (left_t left, right_t right)
 Add the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto and_ (left_t left, right_t right)
 Bitwise and the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto and_also (left_t left, right_t right)
 Logical and the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto compare_three_way (left_t left, right_t right)
 Compare three way the specified left and right operands.
template<auto constant_value>
static constexpr auto constant ()
 Gets the constant value.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto divide (left_t left, right_t right)
 Divide the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto equal (left_t left, right_t right)
 Equal the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto exclusive_or (left_t left, right_t right)
 Bitwise xor the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto greater_than (left_t left, right_t right)
 Greater than the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto greater_than_or_equal (left_t left, right_t right)
 Greater than or equzl the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto left_shift (left_t left, right_t right)
 Left shift the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto less_than (left_t left, right_t right)
 Less than the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto less_than_or_equal (left_t left, right_t right)
 Less than or equal the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto logical_and (left_t left, right_t right)
 Logical and the specified left and right operands.
template<typename value_t>
requires std::is_base_of_v<expression, std::decay_t<value_t>>
static constexpr auto logical_not (value_t value)
 Logical not the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto logical_or (left_t left, right_t right)
 Logical or the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto modulo (left_t left, right_t right)
 Modulo the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto multiply (left_t left, right_t right)
 Multiply the specified left and right operands.
template<typename value_t>
requires std::is_base_of_v<expression, std::decay_t<value_t>>
static constexpr auto negate (value_t value)
 Unary minus the specified left and right operands.
template<typename value_t>
requires std::is_base_of_v<expression, std::decay_t<value_t>>
static constexpr auto not_ (value_t value)
 Bitwise not the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto not_equal (left_t left, right_t right)
 Not equal the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto or_ (left_t left, right_t right)
 Bitwise or the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto or_else (left_t left, right_t right)
 Logical or the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto right_shift (left_t left, right_t right)
 Right shift the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto spaceship (left_t left, right_t right)
 Compare three way the specified left and right operands.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto subtract (left_t left, right_t right)
 Subtract the specified left and right operands.
template<typename value_t>
requires std::is_base_of_v<expression, std::decay_t<value_t>>
static constexpr auto unary_minus (value_t value)
 Unary minus the specified left and right operands.
template<typename value_t>
requires std::is_base_of_v<expression, std::decay_t<value_t>>
static constexpr auto unary_plus (value_t value)
 Unary plus the specified left and right operands.
template<typename type_t>
static constexpr auto value (type_t value)
 Gets the value value.
template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
static constexpr auto xor_ (left_t left, right_t right)
 Bitwise xor the specified left and right operands.

Member Function Documentation

◆ add()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::add ( left_t left,
right_t right )
staticconstexpr

Add the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of add.
Examples
The following example shows how to use xtd::expressions::expression::add.
#include <xtd/xtd>
auto main() -> int {
// auto expr1 = [](auto&& _) {return _ + 10;};
auto expr1 = _ + 10;
println("expr1 = {}", expr1(40));
auto expr2 = expression::add(_, 10);
println("expr2 = {}", expr2(40));
// auto expr3 = [](auto&& _1, auto&& _2) {return _1 + _2;};
auto expr3 = _1 + _2;
println("expr3 = {}", expr3(40, 20));
auto expr4 = expression::add(_1, _2);
println("expr4 = {}", expr4(40, 20));
}
// This code produces the following output :
//
// expr1 = 50
// expr2 = 50
//
// expr3 = 60
// expr4 = 60
constexpr auto _
The xtd::expressions::_ arg instance is used by expression that have only one argument.
Definition args.hpp:68

◆ and_()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::and_ ( left_t left,
right_t right )
staticconstexpr

Bitwise and the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of bitwise and.
Examples
The following example shows how to use xtd::expressions::expression::and_.
#include <xtd/xtd>
auto main() -> int {
// auto expr1 = [](auto&& _) {return _ & 0x0F;};
auto expr1 = _ & 0x0F;
println("expr1 = {:B}", expr1(42));
auto expr2 = expression::and_(_, 0x0F);
println("expr2 = {:B}", expr2(42));
// auto expr3 = [](auto&& _1, auto&& _2) {return _1 & _2;};
auto expr3 = _1 & _2;
println("expr3 = {:B}", expr3(42, 0xF0));
auto expr4 = expression::and_(_1, _2);
println("expr4 = {:B}", expr4(42, 0xF0));
}
// This code produces the following output :
//
// expr1 = 1010
// expr2 = 1010
//
// expr3 = 100000
// expr4 = 100000
static constexpr auto and_(left_t left, right_t right)
Bitwise and the specified left and right operands.

◆ and_also()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::and_also ( left_t left,
right_t right )
staticconstexpr

Logical and the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of logical and.
Remarks
xtd::expressions::expression::and_also is an alias on xtd::expressions::expression::logical_and
Examples
The following example shows how to use xtd::expressions::expression::and_also.
#include <xtd/xtd>
auto main() -> int {
auto value = true;
// auto expr1 = [value](auto&& _) {return _ && value;};
auto expr1 = _ && value;
println("expr1 = {}", expr1(42 % 2 == 0));
auto expr2 = expression::and_also(_, value);
println("expr2 = {}", expr2(42 % 2 == 0));
// auto expr3 = [](auto&& _1, auto&& _2) {return _1 && _2;};
auto expr3 = _1 && _2;
println("expr3 = {}", expr3(42 % 2 == 0, 42 % 8 == 0));
auto expr4 = expression::and_also(_1, _2);
println("expr4 = {}", expr4(42 % 2 == 0, 42 % 8 == 0));
}
// This code produces the following output :
//
// expr1 = true
// expr2 = true
//
// expr3 = false
// expr4 = false
static constexpr auto and_also(left_t left, right_t right)
Logical and the specified left and right operands.

◆ compare_three_way()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::compare_three_way ( left_t left,
right_t right )
staticconstexpr

Compare three way the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of compare three way.
Examples
The following example shows how to use xtd::expressions::expression::compare_three_way.
#include <xtd/xtd>
auto main() -> int {
// auto expr1 = [](auto&& _) {return _ <=> 10;};
auto expr1 = _ <=> 10;
println("expr1 = {}", expr1(42));
auto expr2 = expression::compare_three_way(_, 10);
println("expr2 = {}", expr2(42));
// auto expr3 = [](auto&& _1, auto&& _2) {return _1 <=> _2;};
auto expr3 = _1 <=> _2;
println("expr3 = {}", expr3(42, 42));
println("expr4 = {}", expr4(42, 42));
}
// This code produces the following output :
//
// expr1 = greater
// expr2 = greater
//
// expr3 = equivalent
// expr4 = equivalent
static constexpr auto compare_three_way(left_t left, right_t right)
Compare three way the specified left and right operands.

◆ constant()

template<auto constant_value>
constexpr auto xtd::expressions::expression::constant ( )
staticconstexpr

Gets the constant value.

Parameters
valueThe constnt value.
Returns
The constant value expression.
Examples
The following example shows how to use xtd::expressions::expression::constant.
#include <xtd/xtd>
auto main() -> int {
// auto constant1 = [] {return 10;};
auto constant1 = constant<10> {};
println("constant1 = {}", constant1());
auto constant2 = expression::constant<10>();
println("constant2 = {}", constant2());
constexpr auto value = 30;
//auto constant3 = [value] {return value;};
auto constant3 = constant<value> {};
println("constant3 = {}", constant3());
auto constant4 = expression::constant<value>();
println("constant4 = {}", constant4());
//auto expr1 = [value] {return 20 + value;};
auto expr1 = constant<20> {} + expression::constant<value>();
println("expr1 = {}", expr1());
}
// This code produces the following output :
//
// constant1 = 10
// constant2 = 10
// constant3 = 30
// constant4 = 30
//
// expr1 = 50
The xtd::expressions::constant is the constant wrapper.
Definition constant.hpp:55
static constexpr auto constant()
Gets the constant value.
The xtd::expressions::value is the value wrapper.
Definition value.hpp:55

◆ divide()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::divide ( left_t left,
right_t right )
staticconstexpr

Divide the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of devide.
Examples
The following example shows how to use xtd::expressions::expression::divide.
#include <xtd/xtd>
auto main() -> int {
// auto expr1 = [](auto&& _) {return _ / 10;};
auto expr1 = _ / 10;
println("expr1 = {}", expr1(50));
auto expr2 = expression::divide(_, 10);
println("expr2 = {}", expr2(50));
// auto expr3 = [](auto&& _1, auto&& _2) {return _1 / _2;};
auto expr3 = _1 / _2;
println("expr3 = {}", expr3(60, 15));
auto expr4 = expression::divide(_1, _2);
println("expr4 = {}", expr4(60, 15));
}
// This code produces the following output :
//
// expr1 = 5
// expr2 = 5
//
// expr3 = 4
// expr4 = 4
static constexpr auto divide(left_t left, right_t right)
Divide the specified left and right operands.

◆ equal()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::equal ( left_t left,
right_t right )
staticconstexpr

Equal the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of equal.
Examples
The following example shows how to use xtd::expressions::expression::equal.
#include <xtd/xtd>
auto main() -> int {
// auto equal1 = [](auto&& _) {return _ == 10;};
auto equal1 = _ == 10;
println("equal1 result => {}", equal1(42));
auto equal2 = expression::equal(_, 10);
println("equal2 result => {}", equal2(42));
// auto equal3 = [](auto&& _1, auto&& _2) {return _1 == _2;};
auto equal3 = _1 == _2;
println("equal3 result => {}", equal3(42, 42));
auto equal4 = expression::equal(_1, _2);
println("equal4 result => {}", equal4(42, 42));
}
// This code produces the following output :
//
// equal1 result => false
// equal2 result => false
//
// equal3 result => true
// equal4 result => true
static constexpr auto equal(left_t left, right_t right)
Equal the specified left and right operands.

◆ exclusive_or()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::exclusive_or ( left_t left,
right_t right )
staticconstexpr

Bitwise xor the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of bitwise xor.
Examples
The following example shows how to use xtd::expressions::expression::xor_.
#include <xtd/xtd>
auto main() -> int {
// auto or1 = [](auto&& _) {return _ ^ 0x0F;};
auto xor1 = _ ^ 0x0F;
println("xor1 result => {:B}", xor1(42));
auto xor2 = expression::exclusive_or(_, 0x0F);
println("xor2 result => {:B}", xor2(42));
// auto xor3 = [](auto&& _1, auto&& _2) {return _1 ^ _2;};
auto xor3 = _1 ^ _2;
println("xor3 result => {:B}", xor3(42, 0xF0));
println("xor4 result => {:B}", xor4(42, 0xF0));
}
// This code produces the following output :
//
// xor1 result => 100101
// xor2 result => 100101
//
// xor3 result => 11010010
// xor4 result => 11010010
static constexpr auto exclusive_or(left_t left, right_t right)
Bitwise xor the specified left and right operands.

◆ greater_than()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::greater_than ( left_t left,
right_t right )
staticconstexpr

Greater than the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of greater than.
Examples
The following example shows how to use xtd::expressions::expression::greater_than.
#include <xtd/xtd>
auto main() -> int {
// auto greater_than1 = [](auto&& _) {return _ > 10;};
auto greater_than1 = _ > 10;
println("greater_than1 result => {}", greater_than1(42));
auto greater_than2 = expression::greater_than(_, 10);
println("greater_than2 result => {}", greater_than2(42));
// auto greater_than3 = [](auto&& _1, auto&& _2) {return _1 > _2;};
auto greater_than3 = _1 > _2;
println("greater_than3 result => {}", greater_than3(42, 42));
auto greater_than4 = expression::greater_than(_1, _2);
println("greater_than4 result => {}", greater_than4(42, 42));
}
// This code produces the following output :
//
// greater_than1 result => true
// greater_than2 result => true
//
// greater_than3 result => false
// greater_than4 result => false
static constexpr auto greater_than(left_t left, right_t right)
Greater than the specified left and right operands.

◆ greater_than_or_equal()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::greater_than_or_equal ( left_t left,
right_t right )
staticconstexpr

Greater than or equzl the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of greater than or equal.
Examples
The following example shows how to use xtd::expressions::expression::greater_than_or_equal.
#include <xtd/xtd>
auto main() -> int {
// auto greater_than_or_equal1 = [](auto&& _) {return _ >= 10;};
auto greater_than_or_equal1 = _ > 10;
println("greater_than_or_equal1 result => {}", greater_than_or_equal1(42));
auto greater_than_or_equal2 = expression::greater_than_or_equal(_, 10);
println("greater_than_or_equal2 result => {}", greater_than2(42));
// auto greater_than_or_equal3 = [](auto&& _1, auto&& _2) {return _1 >= _2;};
auto greater_than_or_equal3 = _1 > _2;
println("greater_than_or_equal3 result => {}", greater_than_or_equal2(32, 42));
auto greater_than_or_equal4 = expression::greater_than_or_equal(_1, _2);
println("greater_than_or_equal4 result => {}", greater_than_or_equal4(32, 42));
}
// This code produces the following output :
//
// greater_than_or_equal1 result => true
// greater_than_or_equal2 result => true
//
// greater_than_or_equal3 result => false
// greater_than_or_equal4 result => false
static constexpr auto greater_than_or_equal(left_t left, right_t right)
Greater than or equzl the specified left and right operands.

◆ left_shift()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::left_shift ( left_t left,
right_t right )
staticconstexpr

Left shift the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of left shift.
Examples
The following example shows how to use xtd::expressions::expression::left_shift.
#include <xtd/xtd>
auto main() -> int {
// auto left_shift1 = [](auto&& _) {return _ << 2;};
auto left_shift1 = _ << 2;
println("left_shift1 result => {}", left_shift1(42));
auto left_shift2 = expression::left_shift(_, 2);
println("left_shift2 result => {}", left_shift2(42));
// auto left_shift3 = [](auto&& _1, auto&& _2) {return _1 << _2;};
auto left_shift3 = _1 << _2;
println("left_shift3 result => {}", left_shift3(42, 4));
auto left_shift4 = expression::left_shift(_1, _2);
println("left_shift4 result => {}", left_shift4(42, 4));
}
// This code produces the following output :
//
// left_shift1 result => 168
// left_shift2 result => 168
//
// left_shift3 result => 672
// left_shift4 result => 672
static constexpr auto left_shift(left_t left, right_t right)
Left shift the specified left and right operands.

◆ less_than()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::less_than ( left_t left,
right_t right )
staticconstexpr

Less than the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of less than.
Examples
The following example shows how to use xtd::expressions::expression::less_than.
#include <xtd/xtd>
auto main() -> int {
// auto less_than1 = [](auto&& _) {return _ < 10;};
auto less_than1 = _ < 10;
println("less_than1 result => {}", less_than1(42));
auto less_than2 = expression::less_than(_, 10);
println("less_than2 result => {}", less_than2(42));
// auto less_than3 = [](auto&& _1, auto&& _2) {return _1 < _2;};
auto less_than3 = _1 < _2;
println("less_than3 result => {}", less_than3(42, 52));
auto less_than4 = expression::less_than(_1, _2);
println("less_than4 result => {}", less_than4(42, (52)));
}
// This code produces the following output :
//
// greater_than1 result => false
// greater_than2 result => false
//
// greater_than3 result => true
// greater_than4 result => true
static constexpr auto less_than(left_t left, right_t right)
Less than the specified left and right operands.

◆ less_than_or_equal()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::less_than_or_equal ( left_t left,
right_t right )
staticconstexpr

Less than or equal the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of less than or equal.
Examples
The following example shows how to use xtd::expressions::expression::less_than_or_equal.
#include <xtd/xtd>
auto main() -> int {
// auto less_than_or_equal1 = [](auto&& _) {return _ <= 10;};
auto less_than_or_equal1 = _ <= 10;
println("less_than_or_equal1 result => {}", less_than_or_equal1(42));
auto less_than_or_equal2 = expression::less_than_or_equal(_, 10);
println("less_than_or_equal2 result => {}", less_than_or_equal2(42));
// auto less_than_or_equal3 = [](auto&& _1, auto&& _2) {return _1 <= _2;};
auto less_than_or_equal3 = _1 <= _2;
println("less_than_or_equal3 result => {}", less_than_or_equal3(42, 52));
auto less_than_or_equal4 = expression::less_than_or_equal(_1, _2);
println("less_than_or_equal4 result => {}", less_than_or_equal4(42, (52)));
}
// This code produces the following output :
//
// greater_than1 result => false
// greater_than2 result => false
//
// greater_than3 result => true
// greater_than4 result => true
static constexpr auto less_than_or_equal(left_t left, right_t right)
Less than or equal the specified left and right operands.

◆ logical_and()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::logical_and ( left_t left,
right_t right )
staticconstexpr

Logical and the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of logical and.
Remarks
xtd::expressions::expression::and_also is an alias on xtd::expressions::expression::logical_and
Examples
The following example shows how to use xtd::expressions::expression::logical_and.
#include <xtd/xtd>
auto main() -> int {
auto value = true;
// auto logical_and1 = [value](auto&& _) {return _ && value;};
auto logical_and1 = _ && value;
println("logical_and1 result => {}", logical_and1(42 % 2 == 0));
auto logical_and2 = expression::logical_and(_, value);
println("logical_and2 result => {}", logical_and2(42 % 2 == 0));
// auto logical_and3 = [](auto&& _1, auto&& _2) {return _1 && _2;};
auto logical_and3 = _1 && _2;
println("and_also3 result => {}", logical_and3(42 % 2 == 0, 42 % 8 == 0));
auto logical_and4 = expression::logical_and(_1, _2);
println("logical_and4 result => {}", logical_and4(42 % 2 == 0, 42 % 8 == 0));
}
// This code produces the following output :
//
// logical_and1 result => true
// logical_and2 result => true
//
// logical_and3 result => false
// logical_and4 result => false
static constexpr auto logical_and(left_t left, right_t right)
Logical and the specified left and right operands.

◆ logical_not()

template<typename value_t>
requires std::is_base_of_v<expression, std::decay_t<value_t>>
constexpr auto xtd::expressions::expression::logical_not ( value_t value)
staticconstexpr

Logical not the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of logical not.
Remarks
xtd::expressions::expression::and_also is an alias on xtd::expressions::expression::logical_not
Examples
The following example shows how to use xtd::expressions::expression::logical_not.
#include <xtd/xtd>
auto main() -> int {
// auto logical_not1 = [value](auto&& _) {return !_;};
auto logical_not1 = !_;
println("logical_not1 result => {}", logical_not1(false));
auto logical_not2 = expression::logical_not(_);
println("logical_not2 result => {}", logical_not2(false));
}
// This code produces the following output :
//
// logical_not1 result => true
// logical_not2 result => true
static constexpr auto logical_not(value_t value)
Logical not the specified left and right operands.

◆ logical_or()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::logical_or ( left_t left,
right_t right )
staticconstexpr

Logical or the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of logical or.
Remarks
xtd::expressions::expression::and_also is an alias on xtd::expressions::expression::logical_or
Examples
The following example shows how to use xtd::expressions::expression::logical_or.
#include <xtd/xtd>
auto main() -> int {
auto value = true;
// auto logical_or1 = [value](auto&& _) {return _ || value;};
auto logical_or1 = _ || value;
println("logical_or1 result => {}", logical_or1(42 % 2 == 0));
auto logical_or2 = expression::logical_or(_, value);
println("logical_or2 result => {}", logical_or2(42 % 2 == 0));
// auto logical_or3 = [](auto&& _1, auto&& _2) {return _1 || _2;};
auto logical_or3 = _1 || _2;
println("and_also3 result => {}", logical_or3(42 % 2 != 0, 42 % 8 == 0));
auto logical_or4 = expression::logical_or(_1, _2);
println("logical_or4 result => {}", logical_or4(42 % 2 != 0, 42 % 8 == 0));
}
// This code produces the following output :
//
// logical_or1 result => true
// logical_or2 result => true
//
// logical_or3 result => false
// logical_or4 result => false
static constexpr auto logical_or(left_t left, right_t right)
Logical or the specified left and right operands.

◆ modulo()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::modulo ( left_t left,
right_t right )
staticconstexpr

Modulo the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of modulo.
Examples
The following example shows how to use xtd::expressions::expression::modulo.
#include <xtd/xtd>
auto main() -> int {
// auto modulo1 = [](auto&& _) {return _ % 10;};
auto modulo1 = _ % 10;
println("modulo1 result => {}", modulo1(27));
auto modulo2 = expression::modulo(_, 10);
println("modulo2 result => {}", modulo2(27));
// auto modulo3 = [](auto&& _1, auto&& _2) {return _1 % _2;};
auto modulo3 = _1 % _2;
println("modulo3 result => {}", modulo3(64, 6));
auto modulo4 = expression::modulo(_1, _2);
println("modulo4 result => {}", modulo4(64, 6));
}
// This code produces the following output :
//
// mul1 result => 7
// mul2 result => 7
//
// mul3 result => 4
// mul4 result => 4
static constexpr auto modulo(left_t left, right_t right)
Modulo the specified left and right operands.

◆ multiply()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::multiply ( left_t left,
right_t right )
staticconstexpr

Multiply the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of multiply.
Examples
The following example shows how to use xtd::expressions::expression::multiply.
#include <xtd/xtd>
auto main() -> int {
// auto multiply1 = [](auto&& _) {return _ * 10;};
auto multiply1 = _ * 10;
println("multiply1 result => {}", multiply1(5));
auto multiply2 = expression::multiply(_, 10);
println("multiply2 result => {}", multiply2(5));
// auto multiply3 = [](auto&& _1, auto&& _2) {return _1 * _2;};
auto multiply3 = _1 * _2;
println("multiply3 result => {}", multiply3(4, 15));
auto multiply4 = expression::multiply(_1, _2);
println("multiply4 result => {}", multiply4(4, 15));
}
// This code produces the following output :
//
// mul1 result => 50
// mul2 result => 50
//
// mul3 result => 60
// mul4 result => 60

◆ negate()

template<typename value_t>
requires std::is_base_of_v<expression, std::decay_t<value_t>>
constexpr auto xtd::expressions::expression::negate ( value_t value)
staticconstexpr

Unary minus the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of unary minus.
Remarks
xtd::expressions::expression::and_also is an alias on xtd::expressions::expression::negate
Examples
The following example shows how to use xtd::expressions::expression::negate.
#include <xtd/xtd>
auto main() -> int {
// auto negate1 = [value](auto&& _) {return -_;};
auto negate1 = -_;
println("negate1 result => {}", negate1(42));
auto negate2 = expression::negate(_);
println("negate2 result => {}", negate2(42));
}
// This code produces the following output :
//
// negate1 result => -42
// negate2 result => -42
static constexpr auto negate(value_t value)
Unary minus the specified left and right operands.

◆ not_()

template<typename value_t>
requires std::is_base_of_v<expression, std::decay_t<value_t>>
constexpr auto xtd::expressions::expression::not_ ( value_t value)
staticconstexpr

Bitwise not the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of bistwise not.
Remarks
xtd::expressions::expression::and_also is an alias on xtd::expressions::expression::not_
Examples
The following example shows how to use xtd::expressions::expression::not_.
#include <xtd/xtd>
auto main() -> int {
//auto not1 = [](auto _) {return static_cast<decltype(_)>(~_);};
auto not1 = ~_;
println("not1 result => {:B}", not1(42_u8));
auto not2 = expression::not_(_);
println("unary_plus2 result => {:B}", not2(42));
}
// This code produces the following output :
//
// not1 result => 11010101
// not2 result => 11010101
static constexpr auto not_(value_t value)
Bitwise not the specified left and right operands.

◆ not_equal()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::not_equal ( left_t left,
right_t right )
staticconstexpr

Not equal the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of not equal.
Examples
The following example shows how to use xtd::expressions::expression::not_equal.
#include <xtd/xtd>
auto main() -> int {
// auto not_equal1 = [](auto&& _) {return _ != 10;};
auto not_equal1 = _ != 10;
println("not_equal1 result => {}", not_equal1(42));
auto not_equal2 = expression::not_equal(_, 10);
println("not_equal2 result => {}", not_equal2(42));
// auto not_equal3 = [](auto&& _1, auto&& _2) {return _1 != _2;};
auto not_equal3 = _1 != _2;
println("not_equal3 result => {}", not_equal3(42, 42));
auto not_equal4 = expression::not_equal(_1, _2);
println("not_equal4 result => {}", not_equal4(42, 42));
}
// This code produces the following output :
//
// not_equal1 result => true
// not_equal2 result => true
//
// not_equal3 result => false
// not_equal4 result => false
static constexpr auto not_equal(left_t left, right_t right)
Not equal the specified left and right operands.

◆ or_()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::or_ ( left_t left,
right_t right )
staticconstexpr

Bitwise or the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of bitwise or.
Examples
The following example shows how to use xtd::expressions::expression::or_.
#include <xtd/xtd>
auto main() -> int {
// auto or1 = [](auto&& _) {return _ | 0x0F;};
auto or1 = _ | 0x0F;
println("or1 result => {:B}", or1(42));
auto or2 = expression::or_(_, 0x0F);
println("or2 result => {:B}", or2(42));
// auto or3 = [](auto&& _1, auto&& _2) {return _1 | _2;};
auto or3 = _1 | _2;
println("or3 result => {:B}", or3(42, 0xF0));
auto or4 = expression::or_(_1, _2);
println("or4 result => {:B}", or4(42, 0xF0));
}
// This code produces the following output :
//
// or1 result => 101111
// or2 result => 101111
//
// or3 result => 11111010
// or4 result => 11111010
static constexpr auto or_(left_t left, right_t right)
Bitwise or the specified left and right operands.

◆ or_else()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::or_else ( left_t left,
right_t right )
staticconstexpr

Logical or the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of logical or.
Remarks
xtd::expressions::expression::and_also is an alias on xtd::expressions::expression::or_else
Examples
The following example shows how to use xtd::expressions::expression::or_else.
#include <xtd/xtd>
auto main() -> int {
auto value = true;
// auto or_else1 = [value](auto&& _) {return _ || value;};
auto or_else1 = _ || value;
println("or_else1 result => {}", or_else1(42 % 2 == 0));
auto or_else2 = expression::or_else(_, value);
println("or_else2 result => {}", or_else2(42 % 2 == 0));
// auto or_else3 = [](auto&& _1, auto&& _2) {return _1 || _2;};
auto or_else3 = _1 || _2;
println("and_also3 result => {}", or_else3(42 % 2 != 0, 42 % 8 == 0));
auto or_else4 = expression::or_else(_1, _2);
println("or_else4 result => {}", or_else4(42 % 2 != 0, 42 % 8 == 0));
}
// This code produces the following output :
//
// or_else1 result => true
// or_else2 result => true
//
// or_else3 result => false
// or_else4 result => false
static constexpr auto or_else(left_t left, right_t right)
Logical or the specified left and right operands.

◆ right_shift()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::right_shift ( left_t left,
right_t right )
staticconstexpr

Right shift the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of right shift.
Examples
The following example shows how to use xtd::expressions::expression::right_shift.
#include <xtd/xtd>
auto main() -> int {
// auto right_shift1 = [](auto&& _) {return _ >> 2;};
auto right_shift1 = _ >> 2;
println("right_shift1 result => {}", right_shift1(42));
auto right_shift2 = expression::right_shift(_, 2);
println("right_shift2 result => {}", right_shift2(42));
// auto right_shift3 = [](auto&& _1, auto&& _2) {return _1 >> _2;};
auto right_shift3 = _1 >> _2;
println("right_shift3 result => {}", right_shift3(42, 4));
auto right_shift4 = expression::right_shift(_1, _2);
println("right_shift4 result => {}", right_shift4(42, 4));
}
// This code produces the following output :
//
// right_shift1 result => 10
// right_shift2 result => 10
//
// right_shift3 result => 2
// right_shift4 result => 2
static constexpr auto right_shift(left_t left, right_t right)
Right shift the specified left and right operands.

◆ spaceship()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::spaceship ( left_t left,
right_t right )
staticconstexpr

Compare three way the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of compare three way.
Examples
The following example shows how to use xtd::expressions::expression::spaceship.
#include <xtd/xtd>
auto main() -> int {
// auto cspaceship1 = [value](auto&& _) {return _ <=> 10;};
auto cspaceship1 = _ <=> 10;
println("spaceship1 result => {}", spaceship1(42));
auto spaceship2 = expression::spaceship(_, 10);
println("spaceship2 result => {}", spaceship(42));
//auto spaceship3 = [](auto&& _1, auto&& _2) {return _1 <=> _2;};
auto spaceship3 = _1 <=> _2;
println("spaceship3 result => {}", spaceship3(42, 42));
auto spaceship4 = expression::spaceship(_1, _2);
println("spaceship4 result => {}", spaceship4(42, 42));
}
// This code produces the following output :
//
// spaceship1 result => greater
// spaceship2 result => greater
//
// spaceship3 result => equivalent
// spaceship4 result => equivalent
static constexpr auto spaceship(left_t left, right_t right)
Compare three way the specified left and right operands.

◆ subtract()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::subtract ( left_t left,
right_t right )
staticconstexpr

Subtract the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of subtract.
Examples
The following example shows how to use xtd::expressions::expression::subtract.
#include <xtd/xtd>
auto main() -> int {
// auto subtract1 = [](auto&& _) {return _ - 10;};
auto subtract1 = _ - 10;
println("subtract1 result => {}", subtract1(40));
auto subtract2 = expression::subtract(_, 10);
println("subtract2 result => {}", subtract2(40));
// auto subtract3 = [](auto&& _1, auto&& _2) {return _1 - _2;};
auto subtract3 = _1 - _2;
println("subtract3 result => {}", subtract3(40, 20));
auto subtract4 = expression::subtract(_1, _2);
println("subtract4 result => {}", subtract4(40, 20));
}
// This code produces the following output :
//
// subtract1 result => 30
// subtract2 result => 30
//
// subtract3 result => 20
// subtract4 result => 20
static constexpr auto subtract(left_t left, right_t right)
Subtract the specified left and right operands.

◆ unary_minus()

template<typename value_t>
requires std::is_base_of_v<expression, std::decay_t<value_t>>
constexpr auto xtd::expressions::expression::unary_minus ( value_t value)
staticconstexpr

Unary minus the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of unary minus.
Remarks
xtd::expressions::expression::and_also is an alias on xtd::expressions::expression::unary_minus
Examples
The following example shows how to use xtd::expressions::expression::unary_minus.
#include <xtd/xtd>
auto main() -> int {
// auto unary_minus1 = [value](auto&& _) {return -_;};
auto unary_minus1 = -_;
println("unary_minus1 result => {}", unary_minus1(42));
auto unary_minus2 = expression::unary_minus(_);
println("unary_minus2 result => {}", unary_minus2(42));
}
// This code produces the following output :
//
// unary_minus1 result => -42
// unary_minus2 result => -42
static constexpr auto unary_minus(value_t value)
Unary minus the specified left and right operands.

◆ unary_plus()

template<typename value_t>
requires std::is_base_of_v<expression, std::decay_t<value_t>>
constexpr auto xtd::expressions::expression::unary_plus ( value_t value)
staticconstexpr

Unary plus the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of unary plus.
Remarks
xtd::expressions::expression::and_also is an alias on xtd::expressions::expression::unary_plus
Examples
The following example shows how to use xtd::expressions::expression::unary_plus.
#include <xtd/xtd>
auto main() -> int {
// auto unary_plus1 = [value](auto&& _) {return +_;};
auto unary_plus1 = +_;
println("unary_plus1 result => {}", unary_plus1(42));
auto unary_plus2 = expression::unary_plus(_);
println("unary_plus2 result => {}", unary_plus2(42));
}
// This code produces the following output :
//
// unary_plus1 result => 42
// unary_plus2 result => 42
static constexpr auto unary_plus(value_t value)
Unary plus the specified left and right operands.

◆ value()

template<typename type_t>
constexpr auto xtd::expressions::expression::value ( type_t value)
staticconstexpr

Gets the value value.

Parameters
valueThe value value.
Returns
The value value expression.
Examples
The following example shows how to use xtd::expressions::expression::value.
#include <xtd/xtd>
auto main() -> int {
// auto value1 = [] {return 10;};
auto value1 = value {10};
println("value1 result => {}", value1());
auto value2 = expression::value(10);
println("value2 result => {}", value2());
auto value = 30;
//auto value3 = [value] {return value;};
auto value3 = value {value};
println("value3 result => {}", value3());
auto value4 = expression::value(value);
println("value4 result => {}", value4());
//auto expr1 = [value] {return 20 + value;};
auto expr1 = value {20} + expression::value(value);
println("expr1 result => {}", expr1());
}
// This code produces the following output :
//
// value1 result => 10
// value2 result => 10
// value3 result => 30
// value4 result => 30
//
// expr1 result => 50

◆ xor_()

template<typename left_t, typename right_t>
requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
constexpr auto xtd::expressions::expression::xor_ ( left_t left,
right_t right )
staticconstexpr

Bitwise xor the specified left and right operands.

Parameters
leftThe left operand.
rightThe right operand.
Returns
The result of bitwise xor.
Examples
The following example shows how to use xtd::expressions::expression::xor_.
#include <xtd/xtd>
auto main() -> int {
// auto or1 = [](auto&& _) {return _ ^ 0x0F;};
auto xor1 = _ ^ 0x0F;
println("xor1 result => {:B}", xor1(42));
auto xor2 = expression::xor_(_, 0x0F);
println("xor2 result => {:B}", xor2(42));
// auto xor3 = [](auto&& _1, auto&& _2) {return _1 ^ _2;};
auto xor3 = _1 ^ _2;
println("xor3 result => {:B}", xor3(42, 0xF0));
auto xor4 = expression::xor_(_1, _2);
println("xor4 result => {:B}", xor4(42, 0xF0));
}
// This code produces the following output :
//
// xor1 result => 100101
// xor2 result => 100101
//
// xor3 result => 11010010
// xor4 result => 11010010
static constexpr auto xor_(left_t left, right_t right)
Bitwise xor the specified left and right operands.

Member Data Documentation

◆ arg

template<size_t index>
const xtd::expressions::argument<index> xtd::expressions::expression::arg
static

Gets the index argument used by expression.

Remarks
The index start from 1 to N.
Prefer the xtd::expressions::expression::arg <N> or xtd::expressions::_, xtd::expressions::_1 ... xtd::expressions::_10 instead xtd::expressions::expression::arg.
Examples
The following example shows how to use xtd::expressions::expression::arg.
#include <xtd/xtd>
auto main() -> int {
// auto arg1 = [](auto&& _1) {return _1;};
auto arg1_1 = expression::arg<1>;
println("arg1_1 = {}", arg1_1(10));
// For argument 1 to 10, a second method is possible because the _N are aliases on xtd::expressionq::expression::arg<N>.
auto arg1_2 = _1; // The _N are aliases on xtd::expressions::expression::arg<N>.
println("arg1_2 = {}", arg1_2(10));
// For argument 1, a third method is possible because the _ is an alias on xtd::expressionq::expression::arg<1>.
auto arg1_3 = _; // The _ is an alias on xtd::expressions::expression::arg<1>.
println("arg1_3 = {}", arg1_3(10));
// auto expr = [](auto&& arg1, auto&& arg2, auto&& arg3) {return arg1 + arg2 + arg3;};
println("expr1 = {}", expr1(10, 20, 30));
auto expr2 = _1 + _2 + _3; // The _N are aliases on xtd::expressions::expression::arg<N>.
println("expr2 = {}", expr2(10, 20, 30));
auto expr3 = _ + _2 + _3; // The _ is an alias on xtd::expressions::expression::arg<1>.
println("expr3 = {}", expr3(10, 20, 30));
}
// This code produces the following output :
//
// arg1_1 = 10
// arg1_2 = 10
// arg1_3 = 10
//
// expr1 = 60
// expr2 = 60
// expr3 = 60
constexpr auto _3
The xtd::expressions::_3 arg instance is third argument used by expression.
Definition args.hpp:144
static const xtd::expressions::argument< index > arg
Gets the index argument used by expression.
Definition expression.hpp:95

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