CNL  2.0.2 (development)
Compositional Numeric Library
signedness.h
1 
2 // Copyright John McFarlane 2021.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file ../LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
9 
10 #if !defined(CNL_IMPL_NUMBERS_SIGNEDNESS_H)
11 #define CNL_IMPL_NUMBERS_SIGNEDNESS_H
12 
13 #include "../config.h"
14 #include "../cstdint/types.h"
15 
16 #include <concepts>
17 #include <type_traits>
18 
20 namespace cnl::numbers {
24  template<typename T>
25  struct signedness;
26 
28  template<typename T>
29  requires(std::is_integral_v<T>) struct signedness<T> : std::is_signed<T> {
30  };
32 
34  template<typename T>
35  requires(std::is_floating_point_v<T>) struct signedness<T> : std::true_type {
36  };
38 
40  template<typename T>
41  inline constexpr bool signedness_v = signedness<T>::value;
42 }
43 
44 #endif // CNL_IMPL_NUMBERS_SIGNEDNESS_H
cnl::numbers::signedness
trait with predicate determining that T is a signed number type
Definition: signedness.h:25
std::is_signed
std::true_type
cnl::numbers::signedness_v
constexpr bool signedness_v
true if T is a signed numeric type; false if it is unsigned
Definition: signedness.h:41
cnl::numbers
compositional numeric library, numbers header/namespace
Definition: numbers.h:16