Advertisement
tinyevil

Untitled

May 20th, 2018
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.21 KB | None | 0 0
  1. template<class T>
  2. class nonnull{
  3. public:
  4. nonnull(T& t)
  5. :t(&t){
  6. }
  7.  
  8. operator T&(){
  9. return *t;
  10. }
  11. private:
  12. T* t;
  13. };
  14.  
  15. int main(){
  16. int i;
  17. nonnull<int> x(i); // ok
  18.  
  19. nonnull<int> n; // woops
  20.  
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement