Skip to content

Commit

Permalink
refactor: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mimizh2418 committed Nov 29, 2024
1 parent c7d0fc0 commit 6f3d619
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
SortIncludes: Never
Standard: c++20
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ if(BUILD_EXAMPLES)
target_link_libraries(${example_name} PRIVATE suboptimal)
endif()
endforeach()
endif()
endif()
2 changes: 1 addition & 1 deletion src/LinearProblem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#include <Eigen/Core>

#include "util/assert.h"
#include "util/comparison_util.h"
#include "util/expression_util.h"
#include "util/assert.h"

using namespace Eigen;

Expand Down
2 changes: 1 addition & 1 deletion src/solvers/linear/simplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 9 additions & 3 deletions src/util/FinalAction.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
// Copyright (c) 2024 Alvin Zhang.

#pragma once

#include <type_traits>
#include <utility>

template <class F>
requires std::is_invocable_v<F>
class FinalAction {
public:
public:
explicit FinalAction(const F& f) : f(f) {}
explicit FinalAction(F&& f) : f(std::move(f)) {}

Expand All @@ -12,6 +17,7 @@ class FinalAction {
FinalAction(const FinalAction&) = delete;
void operator=(const FinalAction&) = delete;
void operator=(FinalAction&&) = delete;
private:

private:
F f;
};
};
17 changes: 10 additions & 7 deletions src/util/assert.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
// Copyright (c) 2024 Alvin Zhang.

#pragma once

#ifndef NDEBUG
#include <iostream>

#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) \
Expand Down

0 comments on commit 6f3d619

Please sign in to comment.