Advertisement
Guest User

nullptr98.h

a guest
Jul 28th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #ifndef __NULLPTR98_H__
  2. #define __NULLPTR98_H__
  3.  
  4. #if __cplusplus == 199711L
  5.  
  6. namespace std {
  7.     class nullptr_t {
  8.     public:
  9.         // приводится к любому типу
  10.         template<class T> operator T*() const {
  11.             return 0;
  12.         }
  13.  
  14.         template<class C, class T> operator T C::*() const {
  15.             return 0;
  16.         }
  17.     private:
  18.         // адрес скрыт
  19.         void operator&() const;
  20.     };
  21. }
  22.  
  23. // объявляем в глобальной зоне видимости
  24. std::nullptr_t nullptr = {};
  25.  
  26. #endif // __cplusplus
  27.  
  28. #endif // __NULLPTR98_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement