tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
is_unsigned.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_UNSIGNED_HPP
5#define TETL_TYPE_TRAITS_IS_UNSIGNED_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 {
14
15template <typename T>
16struct is_unsigned : false_type { };
17
18template <typename T>
19 requires is_arithmetic_v<T>
20struct is_unsigned<T> : bool_constant<T(0) < T(-1)> { };
21
22} // namespace detail
23
24/// \brief If T is an arithmetic type, provides the member constant value equal
25/// to true if T(0) < T(-1): this results in true for the unsigned integer types
26/// and the type bool and in false for the signed integer types and the
27/// floating-point types. For any other type, value is false. The behavior of a
28/// program that adds specializations for is_unsigned or is_unsigned_v (since
29/// C++17) is undefined.
30template <typename T>
31struct is_unsigned : detail::is_unsigned<remove_cv_t<T>>::type { };
32
33template <typename T>
34inline constexpr bool is_unsigned_v = is_unsigned<T>::value;
35
36} // namespace etl
37
38#endif // TETL_TYPE_TRAITS_IS_UNSIGNED_HPP
Definition adjacent_find.hpp:9
constexpr bool is_unsigned_v
Definition is_unsigned.hpp:34
If T is an arithmetic type, provides the member constant value equal to true if T(0) < T(-1): this re...
Definition is_unsigned.hpp:31