OASIS
Open Algebra Software
Loading...
Searching...
No Matches
Concepts.hpp
Go to the documentation of this file.
1//
2// Created by Matthew McCall on 10/20/24.
3//
4
5#ifndef OASIS_CONCEPTS_HPP
6#define OASIS_CONCEPTS_HPP
7
8namespace Oasis {
9
10class Expression;
11class Visitor;
12enum class ExpressionType;
13
26template <typename T>
27concept IExpression = (requires(T, const Expression& other) {
28 {
29 T::GetStaticCategory()
31 {
32 T::GetStaticType()
35
36template <template <IExpression, IExpression> class DerivedT, IExpression MostSigOpT, IExpression LeastSigOpT>
38
39template <template <IExpression> class DerivedT, IExpression OpT>
40class UnaryExpression;
41
49template <typename T, typename... U>
50concept IsAnyOf = (std::same_as<T, U> || ...);
51
52template <typename Derived>
53concept DerivedFromBinaryExpression = requires(Derived& d) {
54 []<template <typename, typename> typename D, IExpression T, IExpression U>(BinaryExpression<D, T, U>&) { }(d);
55};
56
57template <typename Derived>
58concept DerivedFromUnaryExpression = requires(Derived& d) {
59 []<template <typename> typename D, IExpression T>(UnaryExpression<D, T>&) { }(d);
60};
61
62template <typename T>
63concept IVisitor = requires {
64 typename T::RetT; // Checks for the type alias
65 requires std::is_base_of_v<Visitor, T>; // Ensures T derives from BaseClass
66};
67
68}
69
70#endif // OASIS_CONCEPTS_HPP
A binary expression.
Definition BinaryExpression.hpp:79
Definition UnaryExpression.hpp:14
Definition Concepts.hpp:53
Definition Concepts.hpp:58
An expression concept.
Definition Concepts.hpp:27
Definition Concepts.hpp:63
Checks if type T is same as any of the provided types in U.
Definition Concepts.hpp:50
T is_same_v
Definition Add.hpp:11
ExpressionType
The type of an expression.
Definition Expression.hpp:19