Skip to content

Commit 14f6105

Browse files
committed
update pre-commit
1 parent 2a71fb4 commit 14f6105

3 files changed

Lines changed: 51 additions & 41 deletions

File tree

.githooks/pre-commit

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
44
cd $SCRIPTPATH/../
55

6-
wsl -- bash -c "make && make test && make build-doc && cp build-linux/zeroerr.hpp ./zeroerr.hpp"
6+
wsl -- bash -c "make && make test && make doc-build && cp build-linux/zeroerr.hpp ./zeroerr.hpp"
7+
8+
git add zeroerr.hpp

include/zeroerr/table.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ class Table {
124124
std::string title;
125125
unsigned width = 0, height = 0; // auto-calculated
126126

127-
128127
std::vector<unsigned> col_width;
129128
std::vector<std::string> header, footer;
130129
std::vector<std::vector<std::string>> cells;

zeroerr.hpp

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
// ======================================================================
44
#pragma once
55

6+
#define ZEROERR_VERSION_MAJOR 0
7+
#define ZEROERR_VERSION_MINOR 1
8+
#define ZEROERR_VERSION_PATCH 0
9+
#define ZEROERR_VERSION (ZEROERR_VERSION_MAJOR * 10000 + ZEROERR_VERSION_MINOR * 100 + ZEROERR_VERSION_PATCH)
10+
611

712
// If you just wish to use the color without dynamic
813
// enable or disable it, you can uncomment the following line
@@ -22,16 +27,28 @@
2227
// #define ZEROERR_DISABLE_COMPLEX_AND_OR
2328

2429

25-
// Detect C++ standard
26-
#if __cplusplus >= 201703L
30+
// Detect C++ standard with a cross-platform way
31+
32+
#ifdef _MSC_VER
33+
#define ZEROERR_CPLUSPLUS _MSVC_LANG
34+
#else
35+
#define ZEROERR_CPLUSPLUS __cplusplus
36+
#endif
37+
38+
#if ZEROERR_CPLUSPLUS >= 202300L
39+
#define ZEROERR_CXX_STANDARD 23
40+
#elif ZEROERR_CPLUSPLUS >= 202002L
41+
#define ZEROERR_CXX_STANDARD 20
42+
#elif ZEROERR_CPLUSPLUS >= 201703L
2743
#define ZEROERR_CXX_STANDARD 17
28-
#elif __cplusplus >= 201402L
44+
#elif ZEROERR_CPLUSPLUS >= 201402L
2945
#define ZEROERR_CXX_STANDARD 14
30-
#else
46+
#elif ZEROERR_CPLUSPLUS >= 201103L
3147
#define ZEROERR_CXX_STANDARD 11
48+
#else
49+
#error "Unsupported C++ standard detected. ZeroErr requires C++11 or later."
3250
#endif
3351

34-
3552
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
3653
#define ZEROERR_OS_UNIX
3754
#if defined(__linux__)
@@ -103,39 +120,11 @@
103120

104121
#define ZEROERR_EXPAND(x) x
105122

106-
namespace zeroerr {
107-
namespace detail {
108-
109-
// Generate sequence of integers from 0 to N-1
110-
// Usage: detail::gen_seq<N> then use <size_t... I> to match it
111-
template <unsigned...>
112-
struct seq {};
113-
114-
template <unsigned N, unsigned... Is>
115-
struct gen_seq : gen_seq<N - 1, N - 1, Is...> {};
116123

117-
template <unsigned... Is>
118-
struct gen_seq<0, Is...> : seq<Is...> {};
119-
120-
} // namespace detail
121-
} // namespace zeroerr
122-
123-
124-
125-
// !!This idea is got from the doctest library.!!
126124
// =================================================================================================
127-
// == COMPILER VERSION =============================================================================
125+
// == COMPILER Detector ============================================================================
128126
// =================================================================================================
129127

130-
// ideas for the version stuff are taken from here: https://github.com/cxxstuff/cxx_detect
131-
#pragma once
132-
133-
#ifdef _MSC_VER
134-
#define ZEROERR_CPLUSPLUS _MSVC_LANG
135-
#else
136-
#define ZEROERR_CPLUSPLUS __cplusplus
137-
#endif
138-
139128
#define ZEROERR_COMPILER(MAJOR, MINOR, PATCH) ((MAJOR) * 10000000 + (MINOR) * 100000 + (PATCH))
140129

141130
// GCC/Clang and GCC/MSVC are mutually exclusive, but Clang/MSVC are not because of clang-cl...
@@ -170,6 +159,7 @@ struct gen_seq<0, Is...> : seq<Is...> {};
170159
#define ZEROERR_ICC 0
171160
#endif // ZEROERR_ICC
172161

162+
173163
// =================================================================================================
174164
// == COMPILER WARNINGS HELPERS ====================================================================
175165
// =================================================================================================
@@ -308,6 +298,26 @@ struct gen_seq<0, Is...> : seq<Is...> {};
308298
#else
309299
#define ZEROERR_UNUSED(x) x
310300
#endif
301+
302+
303+
namespace zeroerr {
304+
namespace detail {
305+
306+
// Generate sequence of integers from 0 to N-1
307+
// Usage: detail::gen_seq<N> then use <size_t... I> to match it
308+
template <unsigned...>
309+
struct seq {};
310+
311+
template <unsigned N, unsigned... Is>
312+
struct gen_seq : gen_seq<N - 1, N - 1, Is...> {};
313+
314+
template <unsigned... Is>
315+
struct gen_seq<0, Is...> : seq<Is...> {};
316+
317+
} // namespace detail
318+
} // namespace zeroerr
319+
320+
311321
#pragma once
312322

313323

@@ -2345,7 +2355,7 @@ struct visit_impl {
23452355
template <>
23462356
struct visit_impl<0> {
23472357
template <typename T, typename F>
2348-
static void visit(T& tup, size_t idx, F& fun) {}
2358+
static void visit(T&, size_t, F&) {}
23492359
};
23502360

23512361
template <typename F, typename... Ts>
@@ -2414,7 +2424,7 @@ extern void resumeLog();
24142424
struct LogMessage {
24152425
LogMessage() { time = std::chrono::system_clock::now(); }
24162426

2417-
virtual std::string str() const = 0;
2427+
virtual std::string str() const = 0;
24182428
virtual void* getRawLog(std::string name) const = 0;
24192429

24202430
// meta data of this log message
@@ -2684,7 +2694,6 @@ class Table {
26842694
std::string title;
26852695
unsigned width = 0, height = 0; // auto-calculated
26862696

2687-
26882697
std::vector<unsigned> col_width;
26892698
std::vector<std::string> header, footer;
26902699
std::vector<std::vector<std::string>> cells;
@@ -2824,15 +2833,15 @@ class CombinationalTest {
28242833
template <typename T>
28252834
void operator()(T& arg) {
28262835
arg.reset();
2827-
for (int i = 0; i < arg.size(); ++i, ++arg) {
2836+
for (size_t i = 0; i < arg.size(); ++i, ++arg) {
28282837
func();
28292838
}
28302839
}
28312840

28322841
template <typename T, typename... Args>
28332842
void operator()(T& arg, Args&... args) {
28342843
arg.reset();
2835-
for (int i = 0; i < arg.size(); ++i, ++arg) {
2844+
for (size_t i = 0; i < arg.size(); ++i, ++arg) {
28362845
operator()(args...);
28372846
}
28382847
}

0 commit comments

Comments
 (0)