type_traits.h (234353) | type_traits.h (239462) |
---|---|
1//===- llvm/Support/type_traits.h - Simplfied type traits -------*- 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//===----------------------------------------------------------------------===// --- 7 unchanged lines hidden (view full) --- 16 17#ifndef LLVM_SUPPORT_TYPE_TRAITS_H 18#define LLVM_SUPPORT_TYPE_TRAITS_H 19 20#include "llvm/Support/DataTypes.h" 21#include <cstddef> 22#include <utility> 23 | 1//===- llvm/Support/type_traits.h - Simplfied type traits -------*- 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//===----------------------------------------------------------------------===// --- 7 unchanged lines hidden (view full) --- 16 17#ifndef LLVM_SUPPORT_TYPE_TRAITS_H 18#define LLVM_SUPPORT_TYPE_TRAITS_H 19 20#include "llvm/Support/DataTypes.h" 21#include <cstddef> 22#include <utility> 23 |
24#ifndef __has_feature 25#define LLVM_DEFINED_HAS_FEATURE 26#define __has_feature(x) 0 27#endif 28 |
|
24// This is actually the conforming implementation which works with abstract 25// classes. However, enough compilers have trouble with it that most will use 26// the one in boost/type_traits/object_traits.hpp. This implementation actually 27// works with VC7.0, but other interactions seem to fail when we use it. 28 29namespace llvm { 30 31namespace dont_use --- 21 unchanged lines hidden (view full) --- 53 enum { value = sizeof(char) == sizeof(dont_use::is_class_helper<T>(0)) }; 54}; 55 56 57/// isPodLike - This is a type trait that is used to determine whether a given 58/// type can be copied around with memcpy instead of running ctors etc. 59template <typename T> 60struct isPodLike { | 29// This is actually the conforming implementation which works with abstract 30// classes. However, enough compilers have trouble with it that most will use 31// the one in boost/type_traits/object_traits.hpp. This implementation actually 32// works with VC7.0, but other interactions seem to fail when we use it. 33 34namespace llvm { 35 36namespace dont_use --- 21 unchanged lines hidden (view full) --- 58 enum { value = sizeof(char) == sizeof(dont_use::is_class_helper<T>(0)) }; 59}; 60 61 62/// isPodLike - This is a type trait that is used to determine whether a given 63/// type can be copied around with memcpy instead of running ctors etc. 64template <typename T> 65struct isPodLike { |
66#if __has_feature(is_trivially_copyable) 67 // If the compiler supports the is_trivially_copyable trait use it, as it 68 // matches the definition of isPodLike closely. 69 static const bool value = __is_trivially_copyable(T); 70#else |
|
61 // If we don't know anything else, we can (at least) assume that all non-class 62 // types are PODs. 63 static const bool value = !is_class<T>::value; | 71 // If we don't know anything else, we can (at least) assume that all non-class 72 // types are PODs. 73 static const bool value = !is_class<T>::value; |
74#endif |
|
64}; 65 66// std::pair's are pod-like if their elements are. 67template<typename T, typename U> 68struct isPodLike<std::pair<T, U> > { 69 static const bool value = isPodLike<T>::value && isPodLike<U>::value; 70}; 71 --- 125 unchanged lines hidden (view full) --- 197template <bool, typename T, typename F> 198struct conditional { typedef T type; }; 199 200template <typename T, typename F> 201struct conditional<false, T, F> { typedef F type; }; 202 203} 204 | 75}; 76 77// std::pair's are pod-like if their elements are. 78template<typename T, typename U> 79struct isPodLike<std::pair<T, U> > { 80 static const bool value = isPodLike<T>::value && isPodLike<U>::value; 81}; 82 --- 125 unchanged lines hidden (view full) --- 208template <bool, typename T, typename F> 209struct conditional { typedef T type; }; 210 211template <typename T, typename F> 212struct conditional<false, T, F> { typedef F type; }; 213 214} 215 |
216#ifdef LLVM_DEFINED_HAS_FEATURE 217#undef __has_feature |
|
205#endif | 218#endif |
219 220#endif |
|