Home | History | Annotate | Line # | Download | only in sanitizer_common
      1 //===-- sanitizer_type_traits.h ---------------------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // Implements a subset of C++ type traits. This is so we can avoid depending
     11 // on system C++ headers.
     12 //
     13 //===----------------------------------------------------------------------===//
     14 #ifndef SANITIZER_TYPE_TRAITS_H
     15 #define SANITIZER_TYPE_TRAITS_H
     16 
     17 namespace __sanitizer {
     18 
     19 struct true_type {
     20   static const bool value = true;
     21 };
     22 
     23 struct false_type {
     24   static const bool value = false;
     25 };
     26 
     27 // is_same<T, U>
     28 //
     29 // Type trait to compare if types are the same.
     30 // E.g.
     31 //
     32 // ```
     33 // is_same<int,int>::value - True
     34 // is_same<int,char>::value - False
     35 // ```
     36 template <typename T, typename U>
     37 struct is_same : public false_type {};
     38 
     39 template <typename T>
     40 struct is_same<T, T> : public true_type {};
     41 
     42 }  // namespace __sanitizer
     43 
     44 #endif
     45