diff --git a/.clang-format b/.clang-format index ae638d5..80dabac 100644 --- a/.clang-format +++ b/.clang-format @@ -6,6 +6,7 @@ AllowShortFunctionsOnASingleLine: Inline AllowShortIfStatementsOnASingleLine: Never AllowShortLoopsOnASingleLine: false ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' ConstructorInitializerAllOnOneLineOrOnePerLine: true SortIncludes: Never Standard: c++20 diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ba27ca..eca0434 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,4 +90,4 @@ if(BUILD_EXAMPLES) target_link_libraries(${example_name} PRIVATE suboptimal) endif() endforeach() -endif() \ No newline at end of file +endif() diff --git a/src/LinearProblem.cpp b/src/LinearProblem.cpp index 80d9540..579ebe2 100644 --- a/src/LinearProblem.cpp +++ b/src/LinearProblem.cpp @@ -8,9 +8,9 @@ #include +#include "util/assert.h" #include "util/comparison_util.h" #include "util/expression_util.h" -#include "util/assert.h" using namespace Eigen; diff --git a/src/solvers/linear/simplex.cpp b/src/solvers/linear/simplex.cpp index dd00724..d5efddf 100644 --- a/src/solvers/linear/simplex.cpp +++ b/src/solvers/linear/simplex.cpp @@ -16,8 +16,8 @@ #include "suboptimal/solvers/linear/SimplexSolverConfig.h" #include "util/FinalAction.h" #include "util/SolverProfiler.h" -#include "util/comparison_util.h" #include "util/assert.h" +#include "util/comparison_util.h" using namespace Eigen; diff --git a/src/util/FinalAction.h b/src/util/FinalAction.h index 15725c4..05aa041 100644 --- a/src/util/FinalAction.h +++ b/src/util/FinalAction.h @@ -1,9 +1,14 @@ +// Copyright (c) 2024 Alvin Zhang. + #pragma once +#include +#include + template requires std::is_invocable_v class FinalAction { -public: + public: explicit FinalAction(const F& f) : f(f) {} explicit FinalAction(F&& f) : f(std::move(f)) {} @@ -12,6 +17,7 @@ class FinalAction { FinalAction(const FinalAction&) = delete; void operator=(const FinalAction&) = delete; void operator=(FinalAction&&) = delete; -private: + + private: F f; -}; \ No newline at end of file +}; diff --git a/src/util/assert.h b/src/util/assert.h index 97f1342..bab71bd 100644 --- a/src/util/assert.h +++ b/src/util/assert.h @@ -1,15 +1,18 @@ +// Copyright (c) 2024 Alvin Zhang. + #pragma once #ifndef NDEBUG #include -#define ASSERT(condition, message) \ - do { \ - if (!(condition)) { \ - std::cerr << "Assertion `" #condition "` failed in " << __FILE__ << " on line " << __LINE__ << ":\n" \ - << message << std::endl; \ - std::abort(); \ - } \ +#define ASSERT(condition, message) \ + do { \ + if (!(condition)) { \ + std::cerr << "Assertion `" #condition "` failed in " << __FILE__ << " on line " << __LINE__ /* NOLINT */ \ + << ":\n" \ + << (message) << std::endl; \ + std::abort(); \ + } \ } while (false) #else #define ASSERT(condition, message) \