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
27template <typename T>
28concept IExpression = (requires(T, const Expression& other) {
29 {
30 T::GetStaticCategory()
32 {
33 T::GetStaticType()
36
37template <template <IExpression, IExpression> class DerivedT, IExpression MostSigOpT, IExpression LeastSigOpT>
39
40template <template <IExpression> class DerivedT, IExpression OpT>
41class UnaryExpression;
42
50template <typename T, typename... U>
51concept IsAnyOf = (std::same_as<T, U> || ...);
52
53template <typename Derived>
54concept DerivedFromBinaryExpression = requires(Derived& d) {
55 []<template <typename, typename> typename D, IExpression T, IExpression U>(BinaryExpression<D, T, U>&) { }(d);
56};
57
58template <typename Derived>
59concept DerivedFromUnaryExpression = requires(Derived& d) {
60 []<template <typename> typename D, IExpression T>(UnaryExpression<D, T>&) { }(d);
61};
62
63template <typename T>
64concept IVisitor = requires {
65 typename T::RetT; // Checks for the type alias
66 requires std::is_base_of_v<Visitor, T>; // Ensures T derives from BaseClass
67};
68
69template <typename T>
70concept ExpectedWithString = requires {
71 typename T::unexpected_type;
73};
74
75}
76
77#endif // OASIS_CONCEPTS_HPP
A binary expression.
Definition BinaryExpression.hpp:82
Definition UnaryExpression.hpp:14
Definition Concepts.hpp:54
Definition Concepts.hpp:59
Definition Concepts.hpp:70
An expression concept.
Definition Concepts.hpp:28
Definition Concepts.hpp:64
Checks if type T is same as any of the provided types in U.
Definition Concepts.hpp:51
T is_same_v
Definition Add.hpp:11
ExpressionType
The type of an expression.
Definition Expression.hpp:22