Skip to content

Commit 4b91c17

Browse files
committed
Correct test for, and use of, concepts for numeric_limits
1 parent cae1528 commit 4b91c17

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Corrected the test for, and use of, concepts when specializing
2+
std::numeric_limits<> for strong::arithmetic types. Thank you
3+
Björn Schäpers for reporting.
4+
15
v9 2023-01-23
26

37
* Lowered the minimum required CMake version to 3.7, unless unit-tests

include/strong_type/arithmetic.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,12 @@ class arithmetic::modifier
166166
}
167167

168168
template <typename T, typename Tag, typename ... Ms>
169+
#if defined(__cpp_concepts)
170+
requires strong::type_is_v<strong::type<T, Tag, Ms...>, strong::arithmetic>
169171
class std::numeric_limits<strong::type<T, Tag, Ms...>>
170-
#if __cplusplus >= 202003L
171-
requires strong::type_is<strong::type<T, Tag, Ms...>, strong::arithmetic>
172-
: public std::numeric_limits<T>
172+
: public std::numeric_limits<T>
173173
#else
174+
class std::numeric_limits<strong::type<T, Tag, Ms...>>
174175
: public std::conditional<
175176
strong::type_is_v<strong::type<T, Tag, Ms...>, strong::arithmetic>,
176177
std::numeric_limits<T>,

test/test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ using uint = unsigned int;
147147
using handle = strong::type<int, struct handle_tag>;
148148

149149
static_assert(!std::numeric_limits<handle>::is_specialized, "");
150+
#if defined(__cpp_concepts)
151+
static_assert(!std::is_base_of<std::numeric_limits<void>, std::numeric_limits<handle>>{},"");
152+
#else
153+
static_assert(std::is_base_of<std::numeric_limits<void>, std::numeric_limits<handle>>{},"");
154+
#endif
150155
static_assert(std::is_same<int, strong::underlying_type_t<handle>>{},"");
151156
static_assert(std::is_same<int, strong::underlying_type_t<int>>{},"");
152157

0 commit comments

Comments
 (0)