limes 3.1.0
Composable Calculus Expressions for C++20
Loading...
Searching...
No Matches
concepts.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <concepts>
4#include <span>
5#include <cstddef>
6
8
9// ExprNode concept: types that represent expression tree nodes
10// Each node has a compile-time arity and can be evaluated with arguments
11template<typename E, typename T>
12concept ExprNode = requires(E const& expr, std::span<T const> args) {
13 { E::arity_v } -> std::convertible_to<std::size_t>;
14 { expr.evaluate(args) } -> std::convertible_to<T>;
15};
16
17// DifferentiableNode: nodes that can compute their derivative with respect to a dimension
18template<typename E, typename T, std::size_t Dim>
19concept DifferentiableNode = ExprNode<E, T> && requires(E const& expr) {
20 { expr.template derivative<Dim>() };
21};
22
23// StringableNode: nodes that can produce a string representation
24template<typename E>
25concept StringableNode = requires(E const& expr) {
26 { expr.to_string() } -> std::convertible_to<std::string>;
27};
28
29} // namespace limes::expr::concepts