All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 namespace blaze {
40 
41 //=================================================================================================
42 //
43 // CLASS DEFINITION
44 //
45 //=================================================================================================
46 
47 //*************************************************************************************************
62 class Null
63 {
64  public:
65  //**Constructor*********************************************************************************
68  inline Null();
70  //**********************************************************************************************
71 
72  //**Destructor**********************************************************************************
73  // No explicitly declared destructor.
74  //**********************************************************************************************
75 
76  //**Conversion operators************************************************************************
79  template< typename T >
80  inline operator T*() const;
81 
82  template< typename T, typename C >
83  inline operator T C::*() const;
85  //**********************************************************************************************
86 
87  //**Utility functions***************************************************************************
90  template< typename T >
91  inline bool equal( const T* rhs ) const;
92 
93  template< typename T, typename C >
94  inline bool equal( const T C::* rhs ) const;
96  //**********************************************************************************************
97 
98  private:
99  //**Forbidden operations************************************************************************
102  Null( const Null& n );
103  Null& operator=( const Null& n );
104  void* operator&() const;
105 
106  //**********************************************************************************************
107 };
108 //*************************************************************************************************
109 
110 
111 
112 
113 //=================================================================================================
114 //
115 // CONSTRUCTOR
116 //
117 //=================================================================================================
118 
119 //*************************************************************************************************
122 inline Null::Null()
123 {}
124 //*************************************************************************************************
125 
126 
127 
128 
129 //=================================================================================================
130 //
131 // CONVERSION OPERATORS
132 //
133 //=================================================================================================
134 
135 //*************************************************************************************************
140 template< typename T >
141 inline Null::operator T*() const
142 {
143  return 0;
144 }
145 //*************************************************************************************************
146 
147 
148 //*************************************************************************************************
154 template< typename T, typename C >
155 inline Null::operator T C::*() const
156 {
157  return 0;
158 }
159 //*************************************************************************************************
160 
161 
162 
163 
164 //=================================================================================================
165 //
166 // UTILITY FUNCTIONS
167 //
168 //=================================================================================================
169 
170 //*************************************************************************************************
175 template< typename T >
176 inline bool Null::equal( const T* rhs ) const
177 {
178  return rhs == 0;
179 }
180 //*************************************************************************************************
181 
182 
183 //*************************************************************************************************
188 template< typename T, typename C >
189 inline bool Null::equal( const T C::* rhs ) const
190 {
191  return rhs == 0;
192 }
193 //*************************************************************************************************
194 
195 
196 
197 
198 //=================================================================================================
199 //
200 // GLOBAL OPERATORS
201 //
202 //=================================================================================================
203 
204 //*************************************************************************************************
207 template< typename T >
208 inline bool operator==( const Null& lhs, const T& rhs );
209 
210 template< typename T >
211 inline bool operator==( const T& lhs, const Null& rhs );
212 
213 template< typename T >
214 inline bool operator!=( const Null& lhs, const T& rhs );
215 
216 template< typename T >
217 inline bool operator!=( const T& lhs, const Null& rhs );
219 //*************************************************************************************************
220 
221 
222 //*************************************************************************************************
229 template< typename T >
230 inline bool operator==( const Null& lhs, const T& rhs )
231 {
232  return lhs.equal( rhs );
233 }
234 //*************************************************************************************************
235 
236 
237 //*************************************************************************************************
244 template< typename T >
245 inline bool operator==( const T& lhs, const Null& rhs )
246 {
247  return rhs.equal( lhs );
248 }
249 //*************************************************************************************************
250 
251 
252 //*************************************************************************************************
259 template< typename T >
260 inline bool operator!=( const Null& lhs, const T& rhs )
261 {
262  return !lhs.equal( rhs );
263 }
264 //*************************************************************************************************
265 
266 
267 //*************************************************************************************************
274 template< typename T >
275 inline bool operator!=( const T& lhs, const Null& rhs )
276 {
277  return !rhs.equal( lhs );
278 }
279 //*************************************************************************************************
280 
281 } // namespace blaze
282 
283 
284 
285 
286 //=================================================================================================
287 //
288 // NULL DEFINITION
289 //
290 //=================================================================================================
291 
292 #undef NULL
293 
294 //*************************************************************************************************
301 //*************************************************************************************************
302 
303 #endif
const blaze::Null NULL
Global NULL pointer.This instance of the Null class replaces the NULL macro to ensure a type-safe NUL...
Definition: Null.h:300
Null & operator=(const Null &n)
Copy assignment operator (private &amp; undefined)
void * operator&() const
Address operator (private &amp; undefined)
Safe C++ NULL pointer implementation.This implementation offers a remedy for the use of the NULL poin...
Definition: Null.h:62
bool equal(const T *rhs) const
Comparison between Null and a pointer.
Definition: Null.h:176
Null()
The default constructor of the Null class.
Definition: Null.h:122
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