tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
is_signed.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_TYPE_TRAITS_IS_SIGNED_HPP
5#define TETL_TYPE_TRAITS_IS_SIGNED_HPP
6
7#include <etl/_type_traits/bool_constant.hpp>
8#include <etl/_type_traits/is_arithmetic.hpp>
9#include <etl/_type_traits/remove_cv.hpp>
10
11namespace etl {
12
13namespace detail {
14template <typename T>
15struct is_signed : false_type { };
16
17template <typename T>
18 requires is_arithmetic_v<T>
19struct is_signed<T> : bool_constant<T(-1) < T(0)> { };
20
21} // namespace detail
22
23/// \brief If T is an arithmetic type, provides the member constant value equal
24/// to true if T(-1) < T(0): this results in true for the floating-point types
25/// and the signed integer types, and in false for the unsigned integer types
26/// and the type bool. For any other type, value is false.
27template <typename T>
28struct is_signed : detail::is_signed<remove_cv_t<T>>::type { };
29
30template <typename T>
31inline constexpr bool is_signed_v = is_signed<T>::value;
32
33} // namespace etl
34
35#endif // TETL_TYPE_TRAITS_IS_SIGNED_HPP
Definition adjacent_find.hpp:9
constexpr bool is_signed_v
Definition is_signed.hpp:31
If T is an arithmetic type, provides the member constant value equal to true if T(-1) < T(0): this re...
Definition is_signed.hpp:28