OpenMPCD
TypeTraits.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * Defines type traits.
4  */
5 
6 #ifndef OPENMPCD_TYPETRAITS_HPP
7 #define OPENMPCD_TYPETRAITS_HPP
8 
9 #include <complex>
10 
11 namespace OpenMPCD
12 {
13  /**
14  * Contains information on certain types.
15  *
16  * The following types are defined:
17  * <table>
18  * <tr>
19  * <th>Name</th>
20  * <th>Meaning</th>
21  * </tr><tr>
22  * <td>RealType</td>
23  * <td>
24  * If T is a floating-point type, this is T.
25  * If T is of the form std::complex<U> for some floating-point type
26  * U, this is U.
27  * </td>
28  * </tr>
29  * </tr><tr>
30  * <td>isStandardFloatingPoint</td>
31  * <td>
32  * Whether `T` is a floating-point type, as defined in the C++
33  * standard (i.e. `float`, `double`, or `long double`).
34  * </td>
35  * </tr><tr>
36  * <td>isComplex</td>
37  * <td>
38  * If T is of the form `std::complex<U>` for some type `U`, this
39  * is `true`, else `false`.
40  * </td>
41  * </tr>
42  * </table>
43  *
44  * @tparam T The type in question.
45  */
46  template<typename T> struct TypeTraits;
47 
48  /**
49  * Specialization of `OpenMPCD::TypeTraits` for `float`.
50  *
51  * @see OpenMPCD::TypeTraits.
52  */
53  template<> struct TypeTraits<float>
54  {
55  typedef float RealType;
56  ///< The type of the real (i.e. non-complex) component.
57 
58  static const bool isStandardFloatingPoint = true;
59  /**< Whether this is one of the language-standard floating point
60  types.*/
61 
62  static const bool isComplex = false;
63  ///< Whether this type is of type `std::complex<U>` for some `U`.
64  };
65 
66  /**
67  * Specialization of `OpenMPCD::TypeTraits` for `double`.
68  *
69  * @see OpenMPCD::TypeTraits.
70  */
71  template<> struct TypeTraits<double>
72  {
73  typedef double RealType;
74  ///< The type of the real (i.e. non-complex) component.
75 
76  static const bool isStandardFloatingPoint = true;
77  /**< Whether this is one of the language-standard floating point
78  types.*/
79 
80  static const bool isComplex = false;
81  ///< Whether this type is of type `std::complex<U>` for some `U`.
82  };
83 
84  /**
85  * Specialization of `OpenMPCD::TypeTraits` for `long double`.
86  *
87  * @see OpenMPCD::TypeTraits.
88  */
89  template<> struct TypeTraits<long double>
90  {
91  typedef long double RealType;
92  ///< The type of the real (i.e. non-complex) component.
93 
94  static const bool isStandardFloatingPoint = true;
95  /**< Whether this is one of the language-standard floating point
96  types.*/
97 
98  static const bool isComplex = false;
99  ///< Whether this type is of type `std::complex<U>` for some `U`.
100  };
101 
102  /**
103  * Specialization of `OpenMPCD::TypeTraits` for `std::complex<float>`.
104  *
105  * @see OpenMPCD::TypeTraits.
106  */
107  template<> struct TypeTraits<std::complex<float> >
108  {
109  typedef float RealType;
110  ///< The type of the real (i.e. non-complex) component.
111 
112  static const bool isStandardFloatingPoint = false;
113  /**< Whether this is one of the language-standard floating point
114  types.*/
115 
116  static const bool isComplex = true;
117  ///< Whether this type is of type `std::complex<U>` for some `U`.
118  };
119 
120  /**
121  * Specialization of `OpenMPCD::TypeTraits` for `std::complex<double>`.
122  *
123  * @see OpenMPCD::TypeTraits.
124  */
125  template<> struct TypeTraits<std::complex<double> >
126  {
127  typedef double RealType;
128  ///< The type of the real (i.e. non-complex) component.
129 
130  static const bool isStandardFloatingPoint = false;
131  /**< Whether this is one of the language-standard floating point
132  types.*/
133 
134  static const bool isComplex = true;
135  ///< Whether this type is of type `std::complex<U>` for some `U`.
136  };
137 
138  /**
139  * Specialization of `OpenMPCD::TypeTraits` for `std::complex<long double>`.
140  *
141  * @see OpenMPCD::TypeTraits.
142  */
143  template<> struct TypeTraits<std::complex<long double> >
144  {
145  typedef long double RealType;
146  ///< The type of the real (i.e. non-complex) component.
147 
148  static const bool isStandardFloatingPoint = false;
149  /**< Whether this is one of the language-standard floating point
150  types.*/
151 
152  static const bool isComplex = true;
153  ///< Whether this type is of type `std::complex<U>` for some `U`.
154  };
155 }
156 
157 #endif
OpenMPCD::TypeTraits< std::complex< float > >::RealType
float RealType
The type of the real (i.e. non-complex) component.
Definition: TypeTraits.hpp:109
OpenMPCD::TypeTraits
Contains information on certain types.
Definition: TypeTraits.hpp:46
OpenMPCD::TypeTraits< long double >::RealType
long double RealType
The type of the real (i.e. non-complex) component.
Definition: TypeTraits.hpp:91
OpenMPCD::TypeTraits< float >::RealType
float RealType
The type of the real (i.e. non-complex) component.
Definition: TypeTraits.hpp:55
OpenMPCD::TypeTraits< std::complex< long double > >::RealType
long double RealType
The type of the real (i.e. non-complex) component.
Definition: TypeTraits.hpp:145
OpenMPCD::TypeTraits< std::complex< double > >::RealType
double RealType
The type of the real (i.e. non-complex) component.
Definition: TypeTraits.hpp:127
OpenMPCD::TypeTraits< double >::RealType
double RealType
The type of the real (i.e. non-complex) component.
Definition: TypeTraits.hpp:73