]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libsanitizer/sanitizer_common/sanitizer_type_traits.h
1 //===-- sanitizer_type_traits.h ---------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // Implements a subset of C++ type traits. This is so we can avoid depending
10 // on system C++ headers.
12 //===----------------------------------------------------------------------===//
13 #ifndef SANITIZER_TYPE_TRAITS_H
14 #define SANITIZER_TYPE_TRAITS_H
16 namespace __sanitizer
{
19 static const bool value
= true;
23 static const bool value
= false;
28 // Type trait to compare if types are the same.
32 // is_same<int,int>::value - True
33 // is_same<int,char>::value - False
35 template <typename T
, typename U
>
36 struct is_same
: public false_type
{};
39 struct is_same
<T
, T
> : public true_type
{};
41 // conditional<B, T, F>
43 // Defines type as T if B is true or as F otherwise.
44 // E.g. the following is true
47 // is_same<int, conditional<true, int, double>::type>::value
48 // is_same<double, conditional<false, int, double>::type>::value
50 template <bool B
, class T
, class F
>
55 template <class T
, class F
>
56 struct conditional
<false, T
, F
> {
60 } // namespace __sanitizer