Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
is_signed.hpp
Go to the documentation of this file.
1// Copyright 2024, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#ifndef INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_IS_SIGNED_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_IS_SIGNED_HPP_
7
8// parasoft-begin-suppress CERT_CPP-DCL58-a-2 "Part of a standard library implementation"
9// parasoft-begin-suppress AUTOSAR-A17_6_1-a-2 "Part of a standard library implementation"
10
11// IWYU pragma: private, include <type_traits>
12// IWYU pragma: friend "stdlib_detail/.*"
13
14#include "stdlib/include/stdlib_detail/integral_constant.hpp"
15#include "stdlib/include/stdlib_detail/is_floating_point.hpp"
16#include "stdlib/include/stdlib_detail/is_integral.hpp"
17
18namespace std {
19
21/// @brief Implementation constant for @c std::is_signed_v The value is @c true if @c Type is a signed type, @c
22/// false otherwise.
23/// @tparam Type The type to check
24template <typename Type, bool = is_integral_v<Type> || is_floating_point_v<Type>>
25extern constexpr bool is_signed_v = false;
26
27/// @brief Implementation constant for @c std::is_signed_v The value is @c true if @c Type is a signed type, @c
28/// false otherwise.
29/// @tparam Type The type to check
30template <typename Type>
31extern constexpr bool is_signed_v<Type, true> =
32 static_cast<Type>(static_cast<Type>(0) - static_cast<Type>(1)) < static_cast<Type>(0);
33
34} // namespace is_signed_detail
35
36/// @brief A type trait to check if a type is signed. The value is @c true if @c Type is a signed type, @c false
37/// otherwise.
38/// @tparam Type The type to check
39template <typename Type>
40extern constexpr bool is_signed_v = is_signed_detail::is_signed_v<Type>;
41
42/// @brief A type trait to check if a type is signed. The class is derived from @c true_type if @c Type is a signed
43/// type, @c false_type otherwise.
44/// @tparam Type The type to check
45template <typename Type>
47
48} // namespace std
49
50#endif // INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_IS_SIGNED_HPP_
A type trait to check if a type is signed. The class is derived from true_type if Type is a signed ty...
Definition is_signed.hpp:46
Definition is_signed.hpp:20
constexpr bool is_signed_v< Type, true >
Implementation constant for std::is_signed_v The value is true if Type is a signed type,...
constexpr bool is_signed_v
Implementation constant for std::is_signed_v The value is true if Type is a signed type,...
constexpr bool is_signed_v
A type trait to check if a type is signed. The value is true if Type is a signed type,...
constexpr auto operator()(::arene::base::result< void, E > const &value) const noexcept(noexcept(hash< E >{}(std::declval< E const & >()))) -> std::size_t
Calculate the hash of a result.
Definition result.hpp:1827