HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
formula_decrement_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_unary_operator_node.hpp"
8#include "../macros.hpp"
9
10hi_export_module(hikogui.formula.formula_decrement_node);
11
12namespace hi { inline namespace v1 {
13
15 formula_decrement_node(size_t line_nr, size_t column_nr, std::unique_ptr<formula_node> rhs) :
16 formula_unary_operator_node(line_nr, column_nr, std::move(rhs))
17 {
18 }
19
21 {
22 auto &rhs_ = rhs->evaluate_lvalue(context);
23 try {
24 return --rhs_;
25 } catch (std::exception const &e) {
26 throw operation_error(std::format("{}:{}: Can not evaluate decrement.\n{}", line_nr, column_nr, e.what()));
27 }
28 }
29
30 std::string string() const noexcept override
31 {
32 return std::format("(-- {})", *rhs);
33 }
34};
35
36}} // 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_decrement_node.hpp:14
datum evaluate(formula_evaluation_context &context) const override
Evaluate an rvalue.
Definition formula_decrement_node.hpp:20
Definition formula_evaluation_context.hpp:18
Definition formula_unary_operator_node.hpp:14
Exception thrown during execution of a dynamic operation.
Definition exception_intf.hpp:160
T move(T... args)
T what(T... args)