Sierra Toolkit  Version of the Day
type_fundamental_eastl.h
1 /*
2 Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7 
8 1. Redistributions of source code must retain the above copyright
9  notice, this list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright
11  notice, this list of conditions and the following disclaimer in the
12  documentation and/or other materials provided with the distribution.
13 3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of
14  its contributors may be used to endorse or promote products derived
15  from this software without specific prior written permission.
16 
17 THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
30 // EASTL/internal/type_fundamental.h
31 //
32 // Written and maintained by Paul Pedriana - 2005.
34 
35 
36 #ifndef EASTL_INTERNAL_TYPE_FUNDAMENTAL_H
37 #define EASTL_INTERNAL_TYPE_FUNDAMENTAL_H
38 
39 
40 namespace eastl
41 {
42 
43  // The following properties or relations are defined here. If the given
44  // item is missing then it simply hasn't been implemented, at least not yet.
45 
46 
48  // is_void
49  //
50  // is_void<T>::value == true if and only if T is one of the following types:
51  // [const][volatile] void
52  //
54  template <typename T> struct is_void : public false_type{};
55 
56  template <> struct is_void<void> : public true_type{};
57  template <> struct is_void<void const> : public true_type{};
58  template <> struct is_void<void volatile> : public true_type{};
59  template <> struct is_void<void const volatile> : public true_type{};
60 
61 
63  // is_integral
64  //
65  // is_integral<T>::value == true if and only if T is one of the following types:
66  // [const] [volatile] bool
67  // [const] [volatile] char
68  // [const] [volatile] signed char
69  // [const] [volatile] unsigned char
70  // [const] [volatile] wchar_t
71  // [const] [volatile] short
72  // [const] [volatile] int
73  // [const] [volatile] long
74  // [const] [volatile] long long
75  // [const] [volatile] unsigned short
76  // [const] [volatile] unsigned int
77  // [const] [volatile] unsigned long
78  // [const] [volatile] unsigned long long
79  //
81  template <typename T> struct is_integral : public false_type{};
82 
83  // To do: Need to define volatile and const volatile versions of these.
84  template <> struct is_integral<unsigned char> : public true_type{};
85  template <> struct is_integral<const unsigned char> : public true_type{};
86  template <> struct is_integral<unsigned short> : public true_type{};
87  template <> struct is_integral<const unsigned short> : public true_type{};
88  template <> struct is_integral<unsigned int> : public true_type{};
89  template <> struct is_integral<const unsigned int> : public true_type{};
90  template <> struct is_integral<unsigned long> : public true_type{};
91  template <> struct is_integral<const unsigned long> : public true_type{};
92  template <> struct is_integral<unsigned long long> : public true_type{};
93  template <> struct is_integral<const unsigned long long> : public true_type{};
94 
95  template <> struct is_integral<signed char> : public true_type{};
96  template <> struct is_integral<const signed char> : public true_type{};
97  template <> struct is_integral<signed short> : public true_type{};
98  template <> struct is_integral<const signed short> : public true_type{};
99  template <> struct is_integral<signed int> : public true_type{};
100  template <> struct is_integral<const signed int> : public true_type{};
101  template <> struct is_integral<signed long> : public true_type{};
102  template <> struct is_integral<const signed long> : public true_type{};
103  template <> struct is_integral<signed long long> : public true_type{};
104  template <> struct is_integral<const signed long long> : public true_type{};
105 
106  template <> struct is_integral<bool> : public true_type{};
107  template <> struct is_integral<const bool> : public true_type{};
108  template <> struct is_integral<char> : public true_type{};
109  template <> struct is_integral<const char> : public true_type{};
110  #ifndef EA_WCHAR_T_NON_NATIVE // If wchar_t is a native type instead of simply a define to an existing type...
111  template <> struct is_integral<wchar_t> : public true_type{};
112  template <> struct is_integral<const wchar_t> : public true_type{};
113  #endif
114 
116  // is_floating_point
117  //
118  // is_floating_point<T>::value == true if and only if T is one of the following types:
119  // [const] [volatile] float
120  // [const] [volatile] double
121  // [const] [volatile] long double
122  //
124  template <typename T> struct is_floating_point : public false_type{};
125 
126  // To do: Need to define volatile and const volatile versions of these.
127  template <> struct is_floating_point<float> : public true_type{};
128  template <> struct is_floating_point<const float> : public true_type{};
129  template <> struct is_floating_point<double> : public true_type{};
130  template <> struct is_floating_point<const double> : public true_type{};
131  template <> struct is_floating_point<long double> : public true_type{};
132  template <> struct is_floating_point<const long double> : public true_type{};
133 
134 
135 
137  // is_arithmetic
138  //
139  // is_arithmetic<T>::value == true if and only if:
140  // is_floating_point<T>::value == true, or
141  // is_integral<T>::value == true
142  //
144  template <typename T>
145  struct is_arithmetic : public integral_constant<bool,
146  is_integral<T>::value || is_floating_point<T>::value
147  >{};
148 
149 
151  // is_fundamental
152  //
153  // is_fundamental<T>::value == true if and only if:
154  // is_floating_point<T>::value == true, or
155  // is_integral<T>::value == true, or
156  // is_void<T>::value == true
158  template <typename T>
159  struct is_fundamental : public integral_constant<bool,
160  is_void<T>::value || is_integral<T>::value || is_floating_point<T>::value
161  >{};
162 
163 } // namespace eastl
164 
165 
166 #endif // Header include guard
EA Standard Template Library.