Skip to content

Commit edcf2a3

Browse files
lemirejaja360
authored andcommitted
minor fixes for systems where from_chars is not supported.
1 parent 73785fe commit edcf2a3

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

benchmarks/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ int main(void) {
1515
return 0;
1616
}
1717
" from_chars_ok)
18-
target_compile_definitions(benchmark PUBLIC FROM_CHARS_SUPPORTED=$<IF:${from_chars_ok},1,0>)
18+
target_compile_definitions(benchmark PUBLIC FROM_CHARS_SUPPORTED=$<IF:$<BOOL:${from_chars_ok}>,1,0>)
1919

2020
if (NOT WIN32)
2121
target_link_libraries(benchmark PUBLIC netlib)

benchmarks/benchmark.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using Benchmarks::arithmetic_float;
2626
using Benchmarks::BenchArgs;
2727

28+
#if FROM_CHARS_SUPPORTED
2829
template <arithmetic_float T>
2930
void evaluateProperties(const std::vector<T> &lines,
3031
const std::array<BenchArgs<T>, Benchmarks::COUNT> &args) {
@@ -49,7 +50,6 @@ void evaluateProperties(const std::vector<T> &lines,
4950
assert(ptr == bufRef.data() + vRef);
5051
assert(ec == std::errc());
5152
assert(d == dRef);
52-
5353
// Tested algorithm output
5454
const int vAlgo = algo.func(d, bufAlgo);
5555
bufAlgo[vAlgo] = '\0';
@@ -64,6 +64,7 @@ void evaluateProperties(const std::vector<T> &lines,
6464
fmt::println("{:20} {:20}", algo.name, incorrect == 0 ? "yes" : "no");
6565
}
6666
}
67+
#endif // FROM_CHARS_SUPPORTED
6768

6869
template <arithmetic_float T>
6970
void process(const std::vector<T> &lines,
@@ -139,10 +140,12 @@ int main(int argc, char **argv) {
139140
"m,model", "Random Model.",
140141
cxxopts::value<std::string>()->default_value("uniform"))(
141142
"s,single", "Use single precision instead of double.",
142-
cxxopts::value<bool>()->default_value("false"))(
143-
"t,test", "Test the algorithms and find their properties.",
144-
cxxopts::value<bool>()->default_value("false"))(
145-
"d,dragon", "Enable dragon4 (current impl. triggers some asserts).",
143+
cxxopts::value<bool>()->default_value("false"))
144+
#if FROM_CHARS_SUPPORTED
145+
("t,test", "Test the algorithms and find their properties.",
146+
cxxopts::value<bool>()->default_value("false"))
147+
#endif // FROM_CHARS_SUPPORTED
148+
("d,dragon", "Enable dragon4 (current impl. triggers some asserts).",
146149
cxxopts::value<bool>()->default_value("false"))(
147150
"e,errol", "Enable errol3 (current impl. returns invalid values, e.g., for 0).",
148151
cxxopts::value<bool>()->default_value("false"))(
@@ -211,9 +214,11 @@ int main(int argc, char **argv) {
211214
using T1 = typename std::decay_t<decltype(lines)>::value_type;
212215
using T2 = typename std::decay_t<decltype(args)>::value_type::Type;
213216
if constexpr (std::is_same_v<T1, T2>) {
217+
#if FROM_CHARS_SUPPORTED
214218
if (test)
215219
evaluateProperties(lines, args);
216220
else
221+
#endif // FROM_CHARS_SUPPORTED
217222
process(lines, args);
218223
}
219224
}, numbers, algorithms);

0 commit comments

Comments
 (0)