All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Null.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_UTIL_NULL_H_
23 #define _BLAZE_UTIL_NULL_H_
24 
25 
26 namespace blaze {
27 
28 //=================================================================================================
29 //
30 // CLASS DEFINITION
31 //
32 //=================================================================================================
33 
34 //*************************************************************************************************
49 class Null
50 {
51  public:
52  //**Constructor*********************************************************************************
55  inline Null();
57  //**********************************************************************************************
58 
59  //**Destructor**********************************************************************************
60  // No explicitly declared destructor.
61  //**********************************************************************************************
62 
63  //**Conversion operators************************************************************************
66  template< typename T >
67  inline operator T*() const;
68 
69  template< typename T, typename C >
70  inline operator T C::*() const;
72  //**********************************************************************************************
73 
74  //**Utility functions***************************************************************************
77  template< typename T >
78  inline bool equal( const T* rhs ) const;
79 
80  template< typename T, typename C >
81  inline bool equal( const T C::* rhs ) const;
83  //**********************************************************************************************
84 
85  private:
86  //**Forbidden operations************************************************************************
89  Null( const Null& n );
90  Null& operator=( const Null& n );
91  void* operator&() const;
92 
93  //**********************************************************************************************
94 };
95 //*************************************************************************************************
96 
97 
98 
99 
100 //=================================================================================================
101 //
102 // CONSTRUCTOR
103 //
104 //=================================================================================================
105 
106 //*************************************************************************************************
109 inline Null::Null()
110 {}
111 //*************************************************************************************************
112 
113 
114 
115 
116 //=================================================================================================
117 //
118 // CONVERSION OPERATORS
119 //
120 //=================================================================================================
121 
122 //*************************************************************************************************
127 template< typename T >
128 inline Null::operator T*() const
129 {
130  return 0;
131 }
132 //*************************************************************************************************
133 
134 
135 //*************************************************************************************************
141 template< typename T, typename C >
142 inline Null::operator T C::*() const
143 {
144  return 0;
145 }
146 //*************************************************************************************************
147 
148 
149 
150 
151 //=================================================================================================
152 //
153 // UTILITY FUNCTIONS
154 //
155 //=================================================================================================
156 
157 //*************************************************************************************************
162 template< typename T >
163 inline bool Null::equal( const T* rhs ) const
164 {
165  return rhs == 0;
166 }
167 //*************************************************************************************************
168 
169 
170 //*************************************************************************************************
175 template< typename T, typename C >
176 inline bool Null::equal( const T C::* rhs ) const
177 {
178  return rhs == 0;
179 }
180 //*************************************************************************************************
181 
182 
183 
184 
185 //=================================================================================================
186 //
187 // GLOBAL OPERATORS
188 //
189 //=================================================================================================
190 
191 //*************************************************************************************************
194 template< typename T >
195 inline bool operator==( const Null& lhs, const T& rhs );
196 
197 template< typename T >
198 inline bool operator==( const T& lhs, const Null& rhs );
199 
200 template< typename T >
201 inline bool operator!=( const Null& lhs, const T& rhs );
202 
203 template< typename T >
204 inline bool operator!=( const T& lhs, const Null& rhs );
206 //*************************************************************************************************
207 
208 
209 //*************************************************************************************************
216 template< typename T >
217 inline bool operator==( const Null& lhs, const T& rhs )
218 {
219  return lhs.equal( rhs );
220 }
221 //*************************************************************************************************
222 
223 
224 //*************************************************************************************************
231 template< typename T >
232 inline bool operator==( const T& lhs, const Null& rhs )
233 {
234  return rhs.equal( lhs );
235 }
236 //*************************************************************************************************
237 
238 
239 //*************************************************************************************************
246 template< typename T >
247 inline bool operator!=( const Null& lhs, const T& rhs )
248 {
249  return !lhs.equal( rhs );
250 }
251 //*************************************************************************************************
252 
253 
254 //*************************************************************************************************
261 template< typename T >
262 inline bool operator!=( const T& lhs, const Null& rhs )
263 {
264  return !rhs.equal( lhs );
265 }
266 //*************************************************************************************************
267 
268 } // namespace blaze
269 
270 
271 
272 
273 //=================================================================================================
274 //
275 // NULL DEFINITION
276 //
277 //=================================================================================================
278 
279 #ifdef NULL
280 # undef NULL
281 #endif
282 
283 //*************************************************************************************************
290 //*************************************************************************************************
291 
292 #endif