Null.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_UTIL_NULL_H_
36 #define _BLAZE_UTIL_NULL_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/system/Null.h>
44 
45 
46 namespace blaze {
47 
48 //=================================================================================================
49 //
50 // CLASS DEFINITION
51 //
52 //=================================================================================================
53 
54 //*************************************************************************************************
69 class Null
70 {
71  public:
72  //**Constructor*********************************************************************************
75  inline Null();
77  //**********************************************************************************************
78 
79  //**Destructor**********************************************************************************
80  // No explicitly declared destructor.
81  //**********************************************************************************************
82 
83  //**Conversion operators************************************************************************
86  template< typename T >
87  inline operator T*() const;
88 
89  template< typename T, typename C >
90  inline operator T C::*() const;
92  //**********************************************************************************************
93 
94  //**Utility functions***************************************************************************
97  template< typename T >
98  inline bool equal( const T* rhs ) const;
99 
100  template< typename T, typename C >
101  inline bool equal( const T C::* rhs ) const;
103  //**********************************************************************************************
104 
105  private:
106  //**Forbidden operations************************************************************************
109  Null( const Null& n );
110  Null& operator=( const Null& n );
111  void* operator&() const;
112 
113  //**********************************************************************************************
114 };
115 //*************************************************************************************************
116 
117 
118 
119 
120 //=================================================================================================
121 //
122 // CONSTRUCTOR
123 //
124 //=================================================================================================
125 
126 //*************************************************************************************************
129 inline Null::Null()
130 {}
131 //*************************************************************************************************
132 
133 
134 
135 
136 //=================================================================================================
137 //
138 // CONVERSION OPERATORS
139 //
140 //=================================================================================================
141 
142 //*************************************************************************************************
147 template< typename T >
148 inline Null::operator T*() const
149 {
150  return 0;
151 }
152 //*************************************************************************************************
153 
154 
155 //*************************************************************************************************
161 template< typename T, typename C >
162 inline Null::operator T C::*() const
163 {
164  return 0;
165 }
166 //*************************************************************************************************
167 
168 
169 
170 
171 //=================================================================================================
172 //
173 // UTILITY FUNCTIONS
174 //
175 //=================================================================================================
176 
177 //*************************************************************************************************
182 template< typename T >
183 inline bool Null::equal( const T* rhs ) const
184 {
185  return rhs == 0;
186 }
187 //*************************************************************************************************
188 
189 
190 //*************************************************************************************************
195 template< typename T, typename C >
196 inline bool Null::equal( const T C::* rhs ) const
197 {
198  return rhs == 0;
199 }
200 //*************************************************************************************************
201 
202 
203 
204 
205 //=================================================================================================
206 //
207 // GLOBAL OPERATORS
208 //
209 //=================================================================================================
210 
211 //*************************************************************************************************
214 template< typename T >
215 inline bool operator==( const Null& lhs, const T& rhs );
216 
217 template< typename T >
218 inline bool operator==( const T& lhs, const Null& rhs );
219 
220 template< typename T >
221 inline bool operator!=( const Null& lhs, const T& rhs );
222 
223 template< typename T >
224 inline bool operator!=( const T& lhs, const Null& rhs );
226 //*************************************************************************************************
227 
228 
229 //*************************************************************************************************
236 template< typename T >
237 inline bool operator==( const Null& lhs, const T& rhs )
238 {
239  return lhs.equal( rhs );
240 }
241 //*************************************************************************************************
242 
243 
244 //*************************************************************************************************
251 template< typename T >
252 inline bool operator==( const T& lhs, const Null& rhs )
253 {
254  return rhs.equal( lhs );
255 }
256 //*************************************************************************************************
257 
258 
259 //*************************************************************************************************
266 template< typename T >
267 inline bool operator!=( const Null& lhs, const T& rhs )
268 {
269  return !lhs.equal( rhs );
270 }
271 //*************************************************************************************************
272 
273 
274 //*************************************************************************************************
281 template< typename T >
282 inline bool operator!=( const T& lhs, const Null& rhs )
283 {
284  return !rhs.equal( lhs );
285 }
286 //*************************************************************************************************
287 
288 } // namespace blaze
289 
290 
291 
292 
293 //=================================================================================================
294 //
295 // NULL DEFINITION
296 //
297 //=================================================================================================
298 
299 #if BLAZE_USE_NULL
300 
301 #undef NULL
302 
303 //*************************************************************************************************
309 const blaze::Null NULL;
310 //*************************************************************************************************
311 
312 #endif
313 
314 #endif
System settings of the NULL policy of the Blaze library.
Null & operator=(const Null &n)
Copy assignment operator (private & undefined)
void * operator&() const
Address operator (private & undefined)
Safe C++ NULL pointer implementation.This implementation offers a remedy for the use of the NULL poin...
Definition: Null.h:69
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
bool equal(const T *rhs) const
Comparison between Null and a pointer.
Definition: Null.h:183
Null()
The default constructor of the Null class.
Definition: Null.h:129
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289