Skip to content

Commit

Permalink
Use noexcept if function doesn't throw any exception
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Apr 9, 2024
1 parent d96aa73 commit 7671a33
Show file tree
Hide file tree
Showing 62 changed files with 128 additions and 128 deletions.
20 changes: 10 additions & 10 deletions include/fintamath/core/MathObjectBody.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@ public: \
private: \
using Class##Parser = detail::Parser<std::unique_ptr<Class>>; \
\
static Class##Parser &getParser() noexcept; \
static Class##Parser &getParser(); \
\
public: \
static auto parse(std::string str) noexcept { \
static auto parse(std::string str) { \
return getParser().parse(std::move(str)); \
} \
\
static auto parseFirst(std::string str) noexcept { \
static auto parseFirst(std::string str) { \
return getParser().parseFirst(std::move(str)); \
} \
\
template <std::derived_from<Class> T> \
static void registerType() noexcept { \
static void registerType() { \
MathObjectIdStorage::add(T::getClassStatic()); \
getParser().registerType<T>(); \
} \
\
private:

#define FINTAMATH_PARENT_CLASS_IMPLEMENTATION(Class) \
FINTAMATH_CLASS_IMPLEMENTATION(Class) \
\
Class::Class##Parser &Class::getParser() noexcept { \
static Class##Parser parser; \
return parser; \
#define FINTAMATH_PARENT_CLASS_IMPLEMENTATION(Class) \
FINTAMATH_CLASS_IMPLEMENTATION(Class) \
\
Class::Class##Parser &Class::getParser() { \
static Class##Parser parser; \
return parser; \
}
6 changes: 3 additions & 3 deletions include/fintamath/core/MathObjectIdStorage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ class MathObjectIdStorage {
using MathObjectClassToIdMap = std::unordered_map<MathObjectClass, size_t>;

public:
static size_t get(MathObjectClass objClass) noexcept;
static size_t get(MathObjectClass objClass);

static void add(MathObjectClass objClass) noexcept;
static void add(MathObjectClass objClass);

private:
static MathObjectClassToIdMap &getMap() noexcept;
static MathObjectClassToIdMap &getMap();

private:
static inline size_t maxId = 1;
Expand Down
2 changes: 1 addition & 1 deletion include/fintamath/core/None.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace fintamath {

struct None {
static constexpr MathObjectClass getClassStatic() {
static constexpr MathObjectClass getClassStatic() noexcept {
return nullptr;
}
};
Expand Down
10 changes: 5 additions & 5 deletions include/fintamath/exceptions/InvalidInputException.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace fintamath {

class InvalidInputException : public Exception {
public:
InvalidInputException() = default;
InvalidInputException() noexcept = default;

explicit InvalidInputException(const std::string &input) {
explicit InvalidInputException(const std::string &input) noexcept {
content += ": " + input;
}

Expand All @@ -26,7 +26,7 @@ class InvalidInputException : public Exception {

class InvalidInputFunctionException final : public InvalidInputException {
public:
explicit InvalidInputFunctionException(const std::string &func, const std::vector<std::string> &argVect) {
explicit InvalidInputFunctionException(const std::string &func, const std::vector<std::string> &argVect) noexcept {
content += ": " + func + "(";

if (!argVect.empty()) {
Expand All @@ -47,7 +47,7 @@ class InvalidInputFunctionException final : public InvalidInputException {

class InvalidInputBinaryOperatorException final : public InvalidInputException {
public:
explicit InvalidInputBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) {
explicit InvalidInputBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) noexcept {
content += ": (" + lhs + ")" + oper + "(" + rhs + ")";
}
};
Expand All @@ -60,7 +60,7 @@ class InvalidInputUnaryOperatorException final : public InvalidInputException {
};

public:
explicit InvalidInputUnaryOperatorException(const std::string &oper, const std::string &rhs, const Type type) {
explicit InvalidInputUnaryOperatorException(const std::string &oper, const std::string &rhs, const Type type) noexcept {
switch (type) {
case Type::Prefix:
content += ": " + oper + "(" + rhs + ")";
Expand Down
10 changes: 5 additions & 5 deletions include/fintamath/exceptions/UndefinedException.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace fintamath {

class UndefinedException : public Exception {
public:
UndefinedException() = default;
UndefinedException() noexcept = default;

explicit UndefinedException(const std::string &input) {
explicit UndefinedException(const std::string &input) noexcept {
content += ": " + input;
}

Expand All @@ -26,7 +26,7 @@ class UndefinedException : public Exception {

class UndefinedFunctionException final : public UndefinedException {
public:
explicit UndefinedFunctionException(const std::string &func, const std::vector<std::string> &argVect) {
explicit UndefinedFunctionException(const std::string &func, const std::vector<std::string> &argVect) noexcept {
content += ": " + func + "(";

if (!argVect.empty()) {
Expand All @@ -47,7 +47,7 @@ class UndefinedFunctionException final : public UndefinedException {

class UndefinedBinaryOperatorException final : public UndefinedException {
public:
explicit UndefinedBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) {
explicit UndefinedBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) noexcept {
content += ": (" + lhs + ")" + oper + "(" + rhs + ")";
}
};
Expand All @@ -60,7 +60,7 @@ class UndefinedUnaryOperatorException final : public UndefinedException {
};

public:
explicit UndefinedUnaryOperatorException(const std::string &oper, const std::string &rhs, const Type type) {
explicit UndefinedUnaryOperatorException(const std::string &oper, const std::string &rhs, const Type type) noexcept {
switch (type) {
case Type::Prefix:
content += ": " + oper + "(" + rhs + ")";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class IPolynomExpression : public IExpression {

ArgumentPtr postSimplify() const override;

virtual bool isTermOrderInversed() const;
virtual bool isTermOrderInversed() const noexcept;

virtual bool isComparableOrderInversed() const;
virtual bool isComparableOrderInversed() const noexcept;

virtual std::strong_ordering compare(const ArgumentPtr &lhs, const ArgumentPtr &rhs) const;

Expand Down
6 changes: 3 additions & 3 deletions include/fintamath/functions/IFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ class IFunction : public IMathObject {
using ClassToOrderMap = std::unordered_map<MathObjectClass, size_t>;

public:
virtual const ArgumentTypeVector &getArgumentClasses() const noexcept = 0;
virtual const ArgumentTypeVector &getArgumentClasses() const = 0;

virtual MathObjectClass getReturnClass() const noexcept = 0;

virtual bool doArgsMatch(const ArgumentRefVector &argVect) const = 0;

virtual bool isVariadic() const = 0;
virtual bool isVariadic() const noexcept = 0;

virtual bool isEvaluatable() const = 0;
virtual bool isEvaluatable() const noexcept = 0;

std::unique_ptr<IMathObject> operator()(const std::derived_from<IMathObject> auto &...args) const {
const ArgumentRefVector argVect = {args...};
Expand Down
12 changes: 6 additions & 6 deletions include/fintamath/functions/IFunctionCRTP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class IFunctionCRTP_ : public IFunction {
#undef I_MATH_OBJECT_CRTP

public:
static const auto &getArgumentClassesStatic() noexcept {
static const auto &getArgumentClassesStatic() {
static const std::array argClasses{Args::getClassStatic()...};
return argClasses;
}

const std::vector<MathObjectClass> &getArgumentClasses() const noexcept final {
const std::vector<MathObjectClass> &getArgumentClasses() const final {
static const auto &argClasses = getArgumentClassesStatic();
static const std::vector<MathObjectClass> argClassesVect(argClasses.begin(), argClasses.end());
return argClassesVect;
Expand All @@ -46,19 +46,19 @@ class IFunctionCRTP_ : public IFunction {
}
}

bool isVariadic() const final {
bool isVariadic() const noexcept final {
return Derived::isVariadicStatic();
}

static constexpr bool isVariadicStatic() {
static constexpr bool isVariadicStatic() noexcept {
return false;
}

bool isEvaluatable() const final {
bool isEvaluatable() const noexcept final {
return Derived::isEvaluatableStatic();
}

static constexpr bool isEvaluatableStatic() {
static constexpr bool isEvaluatableStatic() noexcept {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions include/fintamath/functions/IOperator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class IOperator : public IFunction {
};

public:
virtual Priority getPriority() const = 0;
virtual Priority getPriority() const noexcept = 0;

virtual bool isAssociative() const = 0;
virtual bool isAssociative() const noexcept = 0;
};

template <typename Return, typename Derived, typename... Args>
Expand Down
6 changes: 3 additions & 3 deletions include/fintamath/functions/IOperatorCRTP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class IOperatorCRTP_ : public IOperator {
#undef I_FUNCTION_CRTP

public:
IOperator::Priority getPriority() const final {
IOperator::Priority getPriority() const noexcept final {
return Derived::getPriorityStatic();
}

static constexpr bool isAssociativeStatic() {
static constexpr bool isAssociativeStatic() noexcept {
return false;
}

bool isAssociative() const final {
bool isAssociative() const noexcept final {
return Derived::isAssociativeStatic();
}

Expand Down
2 changes: 1 addition & 1 deletion include/fintamath/functions/arithmetic/Add.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Add : public IFunctionCRTP<IArithmetic, Add, IArithmetic> {
return "add";
}

static constexpr bool isVariadicStatic() {
static constexpr bool isVariadicStatic() noexcept {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions include/fintamath/functions/arithmetic/AddOper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class AddOper : public IOperatorCRTP<IArithmetic, AddOper, IArithmetic, IArithme
return "+";
}

static constexpr bool isAssociativeStatic() {
static constexpr bool isAssociativeStatic() noexcept {
return true;
}

static constexpr Priority getPriorityStatic() {
static constexpr Priority getPriorityStatic() noexcept {
return Priority::Addition;
}

Expand Down
2 changes: 1 addition & 1 deletion include/fintamath/functions/arithmetic/Div.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Div : public IOperatorCRTP<IArithmetic, Div, IArithmetic, IArithmetic> {
return "/";
}

static constexpr Priority getPriorityStatic() {
static constexpr Priority getPriorityStatic() noexcept {
return Priority::Multiplication;
}

Expand Down
2 changes: 1 addition & 1 deletion include/fintamath/functions/arithmetic/Mul.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Mul : public IFunctionCRTP<IArithmetic, Mul, IArithmetic> {
return "mul";
}

static constexpr bool isVariadicStatic() {
static constexpr bool isVariadicStatic() noexcept {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions include/fintamath/functions/arithmetic/MulOper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class MulOper : public IOperatorCRTP<IArithmetic, MulOper, IArithmetic, IArithme
return "*";
}

static constexpr bool isAssociativeStatic() {
static constexpr bool isAssociativeStatic() noexcept {
return true;
}

static constexpr Priority getPriorityStatic() {
static constexpr Priority getPriorityStatic() noexcept {
return Priority::Multiplication;
}

Expand Down
2 changes: 1 addition & 1 deletion include/fintamath/functions/arithmetic/Neg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Neg : public IOperatorCRTP<IArithmetic, Neg, IArithmetic> {
return "-";
}

static constexpr Priority getPriorityStatic() {
static constexpr Priority getPriorityStatic() noexcept {
return Priority::PrefixUnary;
}

Expand Down
2 changes: 1 addition & 1 deletion include/fintamath/functions/arithmetic/Sub.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Sub : public IOperatorCRTP<IArithmetic, Sub, IArithmetic, IArithmetic> {
return "-";
}

static constexpr Priority getPriorityStatic() {
static constexpr Priority getPriorityStatic() noexcept {
return Priority::Addition;
}

Expand Down
2 changes: 1 addition & 1 deletion include/fintamath/functions/arithmetic/UnaryPlus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class UnaryPlus : public IOperatorCRTP<IArithmetic, UnaryPlus, IArithmetic> {
return "+";
}

static constexpr Priority getPriorityStatic() {
static constexpr Priority getPriorityStatic() noexcept {
return Priority::PrefixUnary;
}

Expand Down
2 changes: 1 addition & 1 deletion include/fintamath/functions/calculus/Max.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Max : public IFunctionCRTP<IComparable, Max, IComparable> {
return "max";
}

static constexpr bool isVariadicStatic() {
static constexpr bool isVariadicStatic() noexcept {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion include/fintamath/functions/calculus/Min.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Min : public IFunctionCRTP<IComparable, Min, IComparable> {
return "min";
}

static constexpr bool isVariadicStatic() {
static constexpr bool isVariadicStatic() noexcept {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions include/fintamath/functions/comparison/Eqv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class Eqv : public IOperatorCRTP<Boolean, Eqv, IComparable, IComparable> {
return "=";
}

static constexpr bool isAssociativeStatic() {
static constexpr bool isAssociativeStatic() noexcept {
return true;
}

static constexpr Priority getPriorityStatic() {
static constexpr Priority getPriorityStatic() noexcept {
return Priority::Comparison;
}

Expand Down
4 changes: 2 additions & 2 deletions include/fintamath/functions/comparison/Less.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class Less : public IOperatorCRTP<Boolean, Less, IComparable, IComparable> {
return "<";
}

static constexpr bool isAssociativeStatic() {
static constexpr bool isAssociativeStatic() noexcept {
return true;
}

static constexpr Priority getPriorityStatic() {
static constexpr Priority getPriorityStatic() noexcept {
return Priority::Comparison;
}

Expand Down
4 changes: 2 additions & 2 deletions include/fintamath/functions/comparison/LessEqv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class LessEqv : public IOperatorCRTP<Boolean, LessEqv, IComparable, IComparable>
return "<=";
}

static constexpr bool isAssociativeStatic() {
static constexpr bool isAssociativeStatic() noexcept {
return true;
}

static constexpr Priority getPriorityStatic() {
static constexpr Priority getPriorityStatic() noexcept {
return Priority::Comparison;
}

Expand Down
4 changes: 2 additions & 2 deletions include/fintamath/functions/comparison/More.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class More : public IOperatorCRTP<Boolean, More, IComparable, IComparable> {
return ">";
}

static constexpr bool isAssociativeStatic() {
static constexpr bool isAssociativeStatic() noexcept {
return true;
}

static constexpr Priority getPriorityStatic() {
static constexpr Priority getPriorityStatic() noexcept {
return Priority::Comparison;
}

Expand Down
Loading

0 comments on commit 7671a33

Please sign in to comment.