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
8#include <expected>
9
10namespace Oasis {
11
12class Expression;
13class Visitor;
14enum class ExpressionType;
15
29template <typename T>
30concept IExpression = (requires(T, const Expression& other) {
31 {
32 T::GetStaticCategory()
34 {
35 T::GetStaticType()
38
39template <template <IExpression, IExpression> class DerivedT, IExpression MostSigOpT, IExpression LeastSigOpT>
41
42template <template <IExpression> class DerivedT, IExpression OpT>
43class UnaryExpression;
44
52template <typename T, typename... U>
53concept IsAnyOf = (std::same_as<T, U> || ...);
54
55template <typename Derived>
56concept DerivedFromBinaryExpression = requires(Derived& d) {
57 []<template <typename, typename> typename D, IExpression T, IExpression U>(BinaryExpression<D, T, U>&) { }(d);
58};
59
60template <typename Derived>
61concept DerivedFromUnaryExpression = requires(Derived& d) {
62 []<template <typename> typename D, IExpression T>(UnaryExpression<D, T>&) { }(d);
63};
64
65template <typename T>
66concept IVisitor = requires {
67 typename T::RetT; // Checks for the type alias
68 requires std::is_base_of_v<Visitor, T>; // Ensures T derives from BaseClass
69};
70
71template <typename T>
72concept ExpectedWithString = requires {
73 typename T::unexpected_type;
75};
76
77}
78
79#endif // OASIS_CONCEPTS_HPP
A binary expression.
Definition BinaryExpression.hpp:83
Definition UnaryExpression.hpp:14
Definition Concepts.hpp:56
Definition Concepts.hpp:61
Definition Concepts.hpp:72
An expression concept.
Definition Concepts.hpp:30
Definition Concepts.hpp:66
Checks if type T is same as any of the provided types in U.
Definition Concepts.hpp:53
T is_same_v
Definition Add.hpp:11
ExpressionType
The type of an expression.
Definition Expression.hpp:22