Skip to content

Commit

Permalink
getArgumentClassesStatic and getReturnClassStatic
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Mar 27, 2024
1 parent 0cde547 commit 1e3d3f0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
19 changes: 13 additions & 6 deletions include/fintamath/functions/IFunctionCRTP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,30 @@ class IFunctionCRTP_ : public IFunction {
#undef I_MATH_OBJECT_CRTP

public:
static constexpr auto getArgumentClassesStatic() {
return std::array{Args::getClassStatic()...};
}

const std::vector<MathObjectClass> &getArgumentClasses() const final {
return argTypes;
constexpr auto argClassesArr = getArgumentClassesStatic();
static const std::vector<MathObjectClass> argClassesVect(argClassesArr.begin(), argClassesArr.end());
return argClassesVect;
}

MathObjectClass getReturnClass() const final {
static constexpr MathObjectClass getReturnClassStatic() {
return Return::getClassStatic();
}

MathObjectClass getReturnClass() const final {
return getReturnClassStatic();
}

bool doArgsMatch(const ArgumentRefVector &argVect) const override {
if constexpr (Derived::isVariadicStatic()) {
return doAnyArgsMatch(argVect);
}
else {
if (argVect.size() != argTypes.size()) {
if (argVect.size() != getArgumentClassesStatic().size()) {
return false;
}

Expand Down Expand Up @@ -96,9 +106,6 @@ class IFunctionCRTP_ : public IFunction {
});
}

private:
inline static const ArgumentTypeVector argTypes = {Args::getClassStatic()...};

private:
#if !defined(I_FUNCTION_CRTP) && !defined(NDEBUG)
};
Expand Down
6 changes: 5 additions & 1 deletion include/fintamath/literals/constants/IConstantCRTP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ class IConstantCRTP_ : public IConstant {
#undef I_LITERAL_CRTP

public:
MathObjectClass getReturnClass() const final {
static constexpr MathObjectClass getReturnClassStatic() {
return Return::getClassStatic();
}

MathObjectClass getReturnClass() const final {
return getReturnClassStatic();
}

private:
#if !defined(I_CONSTANT_CRTP) && !defined(NDEBUG)
};
Expand Down

0 comments on commit 1e3d3f0

Please sign in to comment.