ColonelPanic

Core Foundation RAII

Aug 18th, 2011
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. template<typename Ref>
  2. struct ScopedCF
  3. {
  4.     public:
  5.         ScopedCF(Ref r) : r(r) { }
  6.         ~ScopedCF() { if (r) CFRelease(r); }
  7.  
  8.         operator Ref () const { return r; }
  9.         Ref get() const { return r; }
  10.  
  11.     private:
  12.         ScopedCF(const scoped_CF &);
  13.         ScopedCF &operator= (const scoped_CF &);
  14.  
  15.         Ref r;
  16. };
Advertisement
Add Comment
Please, Sign In to add comment