HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
formula_shr_node.hpp
1// Copyright Take Vos 2020-2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "formula_binary_operator_node.hpp"
8#include "../macros.hpp"
9
10hi_export_module(hikogui.formula.formula_shr_node);
11
12namespace hi { inline namespace v1 {
13
15 formula_shr_node(size_t line_nr, size_t column_nr, std::unique_ptr<formula_node> lhs, std::unique_ptr<formula_node> rhs) :
16 formula_binary_operator_node(line_nr, column_nr, std::move(lhs), std::move(rhs))
17 {
18 }
19
21 {
22 auto lhs_ = lhs->evaluate(context);
23 auto rhs_ = rhs->evaluate(context);
24 try {
25 return lhs_ >> rhs_;
26 } catch (std::exception const &e) {
27 throw operation_error(std::format("{}:{}: Can not evaluate shift-right.\n{}", line_nr, column_nr, e.what()));
28 }
29 }
30
31 std::string string() const noexcept override
32 {
33 return std::format("({} >> {})", *lhs, *rhs);
34 }
35};
36
37}} // namespace hi::inline v1
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
A dynamic data type.
Definition datum.hpp:212
Definition formula_binary_operator_node.hpp:14
Definition formula_evaluation_context.hpp:18
Definition formula_shr_node.hpp:14
datum evaluate(formula_evaluation_context &context) const override
Evaluate an rvalue.
Definition formula_shr_node.hpp:20
Exception thrown during execution of a dynamic operation.
Definition exception_intf.hpp:160
T move(T... args)
T what(T... args)