Skip to content

Commit 77c8ac1

Browse files
committed
Use concepts !
1 parent ca6ed44 commit 77c8ac1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.15)
22

33
project(SimpleFastFloatBenchmark VERSION 0.1.0 LANGUAGES CXX C)
4-
set(CMAKE_CXX_STANDARD 17)
4+
set(CMAKE_CXX_STANDARD 20)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66
set(CMAKE_C_STANDARD 99)
77
set(CMAKE_C_STANDARD_REQUIRED ON)

benchmarks/benchmark.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@
5454
#endif
5555

5656
template <typename T>
57+
concept arithmetic_float
58+
= std::is_same_v<T, float> || std::is_same_v<T, double>;
59+
60+
template <arithmetic_float T>
5761
void process(const std::vector<T> &lines) {
58-
static_assert(std::is_same_v<T, float> || std::is_same_v<T, double>,
59-
"The function currently only supports float or double");
6062
using MantissaType = std::conditional_t<std::is_same_v<T, float>,
6163
uint32_t, uint64_t>;
6264
using IEEE754Type = std::conditional_t<std::is_same_v<T, float>,

0 commit comments

Comments
 (0)