xtd 0.2.0
Loading...
Searching...
No Matches
xtd::expressions::expression Struct Reference
Inheritance diagram for xtd::expressions::expression:
xtd::expressions::binary_expression xtd::expressions::conditional_expression xtd::expressions::invocation_expression xtd::expressions::member_expression< expression_t, member_t > xtd::expressions::placeholder_expression xtd::expressions::unary_expression xtd::expressions::value_expression xtd::expressions::add_expression< left_t, right_t > xtd::expressions::and_expression< left_t, right_t > xtd::expressions::compare_three_way_expression< left_t, right_t > xtd::expressions::divide_expression< left_t, right_t > xtd::expressions::equal_expression< left_t, right_t > xtd::expressions::greater_than_expression< left_t, right_t > xtd::expressions::greater_than_or_equal_expression< left_t, right_t > xtd::expressions::left_shift_expression< left_t, right_t > xtd::expressions::less_than_expression< left_t, right_t > xtd::expressions::less_than_or_equal_expression< left_t, right_t > xtd::expressions::logical_and_expression< left_t, right_t > xtd::expressions::modulo_expression< left_t, right_t > xtd::expressions::multiply_expression< left_t, right_t > xtd::expressions::not_equal_expression< left_t, right_t > xtd::expressions::or_else_expression< left_t, right_t > xtd::expressions::or_expression< left_t, right_t > xtd::expressions::right_shift_expression< left_t, right_t > xtd::expressions::subtract_expression< left_t, right_t > xtd::expressions::xor_expression< left_t, right_t > xtd::expressions::method_call_expression< expression_t, method_t > xtd::expressions::placeholder< index > xtd::expressions::logical_not_expression< value_t > xtd::expressions::not_expression< 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::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
xtd::expressions::expression::placeholder
Examples
The following example shos how to use xtd::expressions::expression class.
#include <xtd/xtd>
auto main() -> int {
auto value = 30;
// auto expr1 = [](auto&& _1, auto&& _2) {return (_1 + _2) * value;};
auto expr1 = (_1 + _2) * value;
println("expr1 resutl = {}", expr1(10, 20));
println("expr1 = {}", expr1);
println("type_of(expr1) = {}", type_of(expr1));
println("expr2 resutl = {}", expr2(10, 20));
println("expr2 = {}", expr2);
println("type_of(expr2) = {}", type_of(expr2));
}
// This code produces the following output :
//
// expr1 resutl = 900
// expr1 = (_1 + _2) * 30
// type_of(expr1) = xtd::expressions::multiply_expression<xtd::expressions::add_expression<xtd::expressions::placeholder<1ul>, xtd::expressions::placeholder<2ul>>, xtd::expressions::constant<int>>
//
// expr2 resutl = 900
// expr2 = (_1 + _2) * 30
// type_of(expr2) = xtd::expressions::multiply_expression<xtd::expressions::add_expression<xtd::expressions::placeholder<1ul>, xtd::expressions::placeholder<2ul>>, xtd::expressions::constant<int>>
constexpr auto _2
The xtd::expressions::_2 placeholder instance is second argument used by expression.
Definition args.hpp:117
constexpr auto _1
The xtd::expressions::_1 placeholder instance is first argument used by expression.
Definition args.hpp:92
void println()
Writes the current line terminator to the standard output stream using the specified format informati...
Definition println.hpp:167
static constexpr auto add(left_t left, right_t right)
Add the specified left and right operands.
static constexpr auto multiply(left_t left, right_t right)
Multiply the specified left and right operands.
static constexpr auto value(type_t value)
Gets the value value.

Public Static Methods

template<typename left_t, typename 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>
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>
static constexpr auto and_also (left_t left, right_t right)
 Logical and the specified left and right operands.
template<size_t index>
static constexpr auto arg ()
 Gets the index argument used by expression.
template<typename left_t, typename 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>
static constexpr auto divide (left_t left, right_t right)
 Divide the specified left and right operands.
template<typename left_t, typename 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>
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>
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>
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>
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>
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>
static constexpr auto logical_and (left_t left, right_t right)
 Logical and the specified left and right operands.
template<typename 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>
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>
static constexpr auto modulo (left_t left, right_t right)
 Modulo the specified left and right operands.
template<typename left_t, typename right_t>
static constexpr auto multiply (left_t left, right_t right)
 Multiply the specified left and right operands.
template<typename value_t>
static constexpr auto negate (value_t value)
 Unary minus the specified left and right operands.
template<typename value_t>
static constexpr auto not_ (value_t value)
 Bitwise not the specified left and right operands.
template<typename left_t, typename 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>
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>
static constexpr auto or_else (left_t left, right_t right)
 Logical or the specified left and right operands.
template<size_t index>
static constexpr auto placeholder ()
 Gets the index placeholder used by expression.
template<typename left_t, typename 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>
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>
static constexpr auto subtract (left_t left, right_t right)
 Subtract the specified left and right operands.
template<typename value_t>
static constexpr auto unary_minus (value_t value)
 Unary minus the specified left and right operands.
template<typename 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>
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>
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 add1 = [](auto&& _) {return _ + 10;};
auto add1 = _ + 10;
println("add1 result => {}", add1(40));
auto add2 = expression::add(_, 10);
println("add2 result => {}", add2(40));
// auto add3 = [](auto&& _1, auto&& _2) {return _1 + _2;};
auto add3 = _1 + _2;
println("add3 result => {}", add3(40, 20));
auto add4 = expression::add(_1, _2);
println("add4 result => {}", add4(40, 20));
}
// This code produces the following output :
//
// add1 result => 50
// add2 result => 50
//
// add3 result => 60
// add4 result => 60
constexpr auto _
The xtd::expressions::_ placeholder instance is used by expression that have only one argument.
Definition args.hpp:66

◆ and_()

template<typename left_t, typename 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 and1 = [](auto&& _) {return _ & 0x0F;};
auto and1 = _ & 0x0F;
println("and1 result => {:B}", and1(42));
auto and2 = expression::and_(_, 0x0F);
println("and2 result => {:B}", and2(42));
// auto and3 = [](auto&& _1, auto&& _2) {return _1 & _2;};
auto and3 = _1 & _2;
println("and3 result => {:B}", and3(42, 0xF0));
auto and4 = expression::and_(_1, _2);
println("and4 result => {:B}", and4(42, 0xF0));
}
// This code produces the following output :
//
// and1 result => 1010
// and2 result => 1010
//
// and3 result => 100000
// and4 result => 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>
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 and_also1 = [value](auto&& _) {return _ && value;};
auto and_also1 = _ && value;
println("and_also1 result => {}", and_also1(42 % 2 == 0));
auto and_also2 = expression::and_also(_, value);
println("and_also2 result => {}", and_also2(42 % 2 == 0));
// auto and_also3 = [](auto&& _1, auto&& _2) {return _1 && _2;};
auto and_also3 = _1 && _2;
println("and_also3 result => {}", and_also3(42 % 2 == 0, 42 % 8 == 0));
auto and_also4 = expression::and_also(_1, _2);
println("and_also4 result => {}", and_also4(42 % 2 == 0, 42 % 8 == 0));
}
// This code produces the following output :
//
// and_also1 result => true
// and_also2 result => true
//
// and_also3 result => false
// and_also4 result => false
static constexpr auto and_also(left_t left, right_t right)
Logical and the specified left and right operands.

◆ arg()

template<size_t index>
constexpr auto xtd::expressions::expression::arg ( )
staticconstexpr

Gets the index argument used by expression.

Remarks
The index start from 1 to N.
Examples
The following example shows how to use xtd::expressions::expression::arg.
#include <xtd/xtd>
auto main() -> int {
// auto placeholder1 = [](auto&& _) {return _;};
auto arg1 = _;
println("arg1 result => {}", arg1(10));
auto arg2 = _1;
println("arg2 result => {}", arg2(10));
auto arg3 = arg<1> {};
println("arg3 result => {}", arg3(10));
auto arg4 = expression::arg<1>();
println("arg4 result => {}", arg4(10));
// auto expr1 = [](auto&& _1, auto&& _2, auto&& _3) {return _1 + _2 + _3;};
auto expr1 = _1 + arg<2> + expression::arg<3>();
println("expr1 result => {}", expr1(10, 20, 30));
}
// This code produces the following output :
//
// arg1 result => 10
// arg2 result => 10
// arg3 result => 10
// arg4 result => 10
//
// expr1 result => 60
constexpr xtd::expressions::placeholder< index > arg
The xtd::expressions::arg instance is the index argument used by expression.
Definition arg.hpp:61
static constexpr auto arg()
Gets the index argument used by expression.

◆ compare_three_way()

template<typename left_t, typename 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 compare_three_way1 = [value](auto&& _) {return _ <=> 10;};
auto compare_three_way1 = _ <=> 10;
println("compare_three_way1 result => {}", compare_three_way1(42));
auto compare_three_way2 = expression::compare_three_way(_, 10);
println("compare_three_way2 result => {}", compare_three_way2(42));
//auto compare_three_way3 = [](auto&& _1, auto&& _2) {return _1 <=> _2;};
auto compare_three_way3 = _1 <=> _2;
println("compare_three_way3 result => {}", compare_three_way3(42, 42));
auto compare_three_way4 = expression::compare_three_way(_1, _2);
println("compare_three_way4 result => {}", compare_three_way4(42, 42));
}
// This code produces the following output :
//
// compare_three_way1 result => greater
// compare_three_way2 result => greater
//
// compare_three_way3 result => equivalent
// compare_three_way4 result => 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 result => {}", constant1());
auto constant2 = expression::constant<10>();
println("constant2 result => {}", constant2());
auto value = 30;
//auto constant3 = [value] {return value;};
auto constant3 = constant<value> {};
println("constant3 result => {}", constant3());
auto constant4 = expression::constant<value>();
println("constant4 result => {}", constant4());
//auto expr1 = [value] {return 20 + value;};
println("expr1 result => {}", expr1());
}
// This code produces the following output :
//
// constant1 result => 10
// constant2 result => 10
// constant3 result => 30
// constant4 result => 30
//
// expr1 result => 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>
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 divide1 = [](auto&& _) {return _ / 10;};
auto divide1 = _ / 10;
println("divide1 result => {}", divide1(50));
auto divide2 = expression::divide(_, 10);
println("divide2 result => {}", divide2(50));
// auto divide3 = [](auto&& _1, auto&& _2) {return _1 / _2;};
auto divide3 = _1 / _2;
println("add3 result => {}", divide3(60, 15));
auto divide4 = expression::divide(_1, _2);
println("add4 result => {}", divide4(60, 15));
}
// This code produces the following output :
//
// divide1 result => 5
// divide2 result => 5
//
// divide3 result => 4
// divide4 result => 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>
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.

◆ greater_than()

template<typename left_t, typename 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.

◆ placeholder()

template<size_t index>
constexpr auto xtd::expressions::expression::placeholder ( )
staticconstexpr

Gets the index placeholder 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::placeholder.
Examples
The following example shows how to use xtd::expressions::expression::placeholder.
#include <xtd/xtd>
auto main() -> int {
// auto placeholder1 = [](auto&& _) {return _;};
auto placeholder1 = _;
println("placeholder1 result => {}", placeholder1(10));
auto placeholder2 = _1;
println("placeholder2 result => {}", placeholder2(10));
auto placeholder3 = placeholder<1> {};
println("placeholder3 result => {}", placeholder3(10));
auto placeholder4 = expression::placeholder<1>();
println("placeholder4 result => {}", placeholder4(10));
// auto expr1 = [](auto&& _1, auto&& _2, auto&& _3) {return _1 + _2 + _3;};
println("expr1 result => {}", expr1(10, 20, 30));
}
// This code produces the following output :
//
// placeholder1 result => 10
// placeholder2 result => 10
// placeholder3 result => 10
// placeholder4 result => 10
//
// expr1 result => 60
static constexpr auto placeholder()
Gets the index placeholder used by expression.
The xtd::expressions::placeholder object is placeholder for all expressions.
Definition placeholder.hpp:58

◆ right_shift()

template<typename left_t, typename 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>
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>
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>
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>
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>
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.

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