diff --git a/include/fintamath/functions/IFunctionCRTP.hpp b/include/fintamath/functions/IFunctionCRTP.hpp index 79d757058..c523e6405 100644 --- a/include/fintamath/functions/IFunctionCRTP.hpp +++ b/include/fintamath/functions/IFunctionCRTP.hpp @@ -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 &getArgumentClasses() const final { - return argTypes; + constexpr auto argClassesArr = getArgumentClassesStatic(); + static const std::vector 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; } @@ -96,9 +106,6 @@ class IFunctionCRTP_ : public IFunction { }); } -private: - inline static const ArgumentTypeVector argTypes = {Args::getClassStatic()...}; - private: #if !defined(I_FUNCTION_CRTP) && !defined(NDEBUG) }; diff --git a/include/fintamath/literals/constants/IConstantCRTP.hpp b/include/fintamath/literals/constants/IConstantCRTP.hpp index 7d28d8c4e..8e1776ebb 100644 --- a/include/fintamath/literals/constants/IConstantCRTP.hpp +++ b/include/fintamath/literals/constants/IConstantCRTP.hpp @@ -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) };