xtd 0.2.0
Loading...
Searching...
No Matches
logical_or_expression.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "as_expression.hpp"
9#include <utility>
10
12namespace xtd {
14 namespace expressions {
26 template <typename left_t, typename right_t>
27 struct logical_or_expression : binary_expression {
29
32 static constexpr operator_precedence precedence = operator_precedence::logical_and;
34
36
39 constexpr logical_or_expression() = default;
40
44 constexpr logical_or_expression(left_t left, right_t right) : left {std::move(left)}, right {std::move(right)} {}
46
48
53 template <typename... args_t>
54 constexpr auto operator()(args_t&&... args) const {return left(std::forward<args_t>(args)...) || right(std::forward<args_t>(args)...);}
56
58 friend inline auto operator <<(std::ostream& os, const logical_or_expression& e) -> std::ostream& {return os << expression_stream {e.left, e.precedence} << " || " << expression_stream {e.right, e.precedence};}
60
61 private:
62 [[no_unique_address]] left_t left;
63 [[no_unique_address]] right_t right;
64 };
65
67 template <typename left_t, typename right_t>
68 requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
69 constexpr auto expression::or_else(left_t left, right_t right) {return expression::logical_or(std::move(left), std::move(right));}
70
71 template <typename left_t, typename right_t>
72 requires std::is_base_of_v<expression, std::decay_t<left_t>> || std::is_base_of_v<expression, std::decay_t<right_t>>
73 constexpr auto expression::logical_or(left_t left, right_t right) {
74 auto left_expression = as_expression(left);
75 auto right_expression = as_expression(right);
76 return logical_or_expression<std::decay_t<decltype(left_expression)>, std::decay_t<decltype(right_expression)>> {std::move(left_expression), std::move(right_expression)};
77 }
78
80
123 template <typename left_t, typename right_t>
125 constexpr auto operator ||(left_t left, right_t right) {return expression::logical_or(std::move(left), std::move(right));}
127 }
128}
Contains xtd::expressions::as_expression methods.
Contains xtd::expressions::binary_expression struct.
The xtd::expressions::expression_operand object is expression operand concept.
Definition expression_operand.hpp:27
Contains xtd::expressions::expression_operand concept.
Contains xtd::expressions::expression_stream struct.
operator_precedence
Specifies the operator precedence.
Definition operator_precedence.hpp:22
constexpr decltype(auto) as_expression(type_t &&value)
The xtd::expressions::as_expression method convert a type as xtd::expressions::expression.
Definition as_expression.hpp:33
constexpr auto operator||(left_t left, right_t right)
Equal to the specified left and right operands.
Definition or_else_expression.hpp:98
@ e
The E key.
Definition console_key.hpp:96
@ right
Specifies the xtd::drawing::pen is positioned to the right of the theoretical line.
Definition pen_alignment.hpp:31
@ left
Specifies the xtd::drawing::pen is positioned to the left of the theoretical line.
Definition pen_alignment.hpp:29
The xtd::expressions namespace provides a lightweight, composable expression template framework for b...
Definition add_expression.hpp:14
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
The xtd::expressions::binary_expression is the base class for xtd::expressions::placeholder.
Definition binary_expression.hpp:21
static constexpr auto logical_or(left_t left, right_t right)
Logical or the specified left and right operands.
static constexpr auto or_else(left_t left, right_t right)
Logical or the specified left and right operands.