HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
formula_add_node.hpp
1// Copyright Take Vos 2020.
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
9namespace tt {
10
14
15 datum evaluate(formula_evaluation_context& context) const override {
16 auto lhs_ = lhs->evaluate(context);
17 auto rhs_ = rhs->evaluate(context);
18 try {
19 return lhs_ + rhs_;
20 } catch (...) {
21 auto error_location = location;
22 if (auto formula_location = error_info::peek<parse_location, "parse_location">()) {
23 error_location += *formula_location;
24 }
25 error_info(true).set<"parse_location">(error_location);
26 throw;
27 }
28 }
29
30 std::string string() const noexcept override {
31 return fmt::format("({} + {})", *lhs, *rhs);
32 }
33};
34
35}
Error information passed alongside an error code or exception.
Definition error_info.hpp:81
error_info & set(Arg &&value) noexcept
Set an information for a given tag.
Definition error_info.hpp:144
Definition formula_add_node.hpp:11
datum evaluate(formula_evaluation_context &context) const override
Evaluate an rvalue.
Definition formula_add_node.hpp:15
Definition formula_binary_operator_node.hpp:11
Definition formula_evaluation_context.hpp:16
Definition parse_location.hpp:16
T move(T... args)