|
3 | 3 | // ====================================================================== |
4 | 4 | #pragma once |
5 | 5 |
|
| 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 | + |
6 | 11 |
|
7 | 12 | // If you just wish to use the color without dynamic |
8 | 13 | // enable or disable it, you can uncomment the following line |
|
22 | 27 | // #define ZEROERR_DISABLE_COMPLEX_AND_OR |
23 | 28 |
|
24 | 29 |
|
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 |
27 | 43 | #define ZEROERR_CXX_STANDARD 17 |
28 | | -#elif __cplusplus >= 201402L |
| 44 | +#elif ZEROERR_CPLUSPLUS >= 201402L |
29 | 45 | #define ZEROERR_CXX_STANDARD 14 |
30 | | -#else |
| 46 | +#elif ZEROERR_CPLUSPLUS >= 201103L |
31 | 47 | #define ZEROERR_CXX_STANDARD 11 |
| 48 | +#else |
| 49 | +#error "Unsupported C++ standard detected. ZeroErr requires C++11 or later." |
32 | 50 | #endif |
33 | 51 |
|
34 | | - |
35 | 52 | #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) |
36 | 53 | #define ZEROERR_OS_UNIX |
37 | 54 | #if defined(__linux__) |
|
103 | 120 |
|
104 | 121 | #define ZEROERR_EXPAND(x) x |
105 | 122 |
|
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...> {}; |
116 | 123 |
|
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.!! |
126 | 124 | // ================================================================================================= |
127 | | -// == COMPILER VERSION ============================================================================= |
| 125 | +// == COMPILER Detector ============================================================================ |
128 | 126 | // ================================================================================================= |
129 | 127 |
|
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 | | - |
139 | 128 | #define ZEROERR_COMPILER(MAJOR, MINOR, PATCH) ((MAJOR) * 10000000 + (MINOR) * 100000 + (PATCH)) |
140 | 129 |
|
141 | 130 | // 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...> {}; |
170 | 159 | #define ZEROERR_ICC 0 |
171 | 160 | #endif // ZEROERR_ICC |
172 | 161 |
|
| 162 | + |
173 | 163 | // ================================================================================================= |
174 | 164 | // == COMPILER WARNINGS HELPERS ==================================================================== |
175 | 165 | // ================================================================================================= |
@@ -308,6 +298,26 @@ struct gen_seq<0, Is...> : seq<Is...> {}; |
308 | 298 | #else |
309 | 299 | #define ZEROERR_UNUSED(x) x |
310 | 300 | #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 | + |
311 | 321 | #pragma once |
312 | 322 |
|
313 | 323 |
|
@@ -2345,7 +2355,7 @@ struct visit_impl { |
2345 | 2355 | template <> |
2346 | 2356 | struct visit_impl<0> { |
2347 | 2357 | template <typename T, typename F> |
2348 | | - static void visit(T& tup, size_t idx, F& fun) {} |
| 2358 | + static void visit(T&, size_t, F&) {} |
2349 | 2359 | }; |
2350 | 2360 |
|
2351 | 2361 | template <typename F, typename... Ts> |
@@ -2414,7 +2424,7 @@ extern void resumeLog(); |
2414 | 2424 | struct LogMessage { |
2415 | 2425 | LogMessage() { time = std::chrono::system_clock::now(); } |
2416 | 2426 |
|
2417 | | - virtual std::string str() const = 0; |
| 2427 | + virtual std::string str() const = 0; |
2418 | 2428 | virtual void* getRawLog(std::string name) const = 0; |
2419 | 2429 |
|
2420 | 2430 | // meta data of this log message |
@@ -2684,7 +2694,6 @@ class Table { |
2684 | 2694 | std::string title; |
2685 | 2695 | unsigned width = 0, height = 0; // auto-calculated |
2686 | 2696 |
|
2687 | | - |
2688 | 2697 | std::vector<unsigned> col_width; |
2689 | 2698 | std::vector<std::string> header, footer; |
2690 | 2699 | std::vector<std::vector<std::string>> cells; |
@@ -2824,15 +2833,15 @@ class CombinationalTest { |
2824 | 2833 | template <typename T> |
2825 | 2834 | void operator()(T& arg) { |
2826 | 2835 | arg.reset(); |
2827 | | - for (int i = 0; i < arg.size(); ++i, ++arg) { |
| 2836 | + for (size_t i = 0; i < arg.size(); ++i, ++arg) { |
2828 | 2837 | func(); |
2829 | 2838 | } |
2830 | 2839 | } |
2831 | 2840 |
|
2832 | 2841 | template <typename T, typename... Args> |
2833 | 2842 | void operator()(T& arg, Args&... args) { |
2834 | 2843 | arg.reset(); |
2835 | | - for (int i = 0; i < arg.size(); ++i, ++arg) { |
| 2844 | + for (size_t i = 0; i < arg.size(); ++i, ++arg) { |
2836 | 2845 | operator()(args...); |
2837 | 2846 | } |
2838 | 2847 | } |
|
0 commit comments