1//===-- is_signed type_traits -----------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/CPP/type_traits/is_arithmetic.h"
13#include "src/__support/macros/attributes.h"
14
15namespace LIBC_NAMESPACE::cpp {
16
17// is_signed
18template <typename T>
19struct is_signed : bool_constant<(is_arithmetic_v<T> && (T(-1) < T(0)))> {
20 LIBC_INLINE constexpr operator bool() const { return is_signed::value; }
21 LIBC_INLINE constexpr bool operator()() const { return is_signed::value; }
22};
23template <typename T>
24LIBC_INLINE_VAR constexpr bool is_signed_v = is_signed<T>::value;
25
26} // namespace LIBC_NAMESPACE::cpp
27
28#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H
29

source code of libc/src/__support/CPP/type_traits/is_signed.h