vrshoot

view libs/assimp/boost/scoped_ptr.hpp @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line source
2 #ifndef __AI_BOOST_SCOPED_PTR_INCLUDED
3 #define __AI_BOOST_SCOPED_PTR_INCLUDED
5 #ifndef BOOST_SCOPED_PTR_HPP_INCLUDED
7 namespace boost {
9 // small replacement for boost::scoped_ptr
10 template <class T>
11 class scoped_ptr
12 {
13 public:
15 // provide a default construtctor
16 scoped_ptr()
17 : ptr(0)
18 {
19 }
21 // construction from an existing heap object of type T
22 scoped_ptr(T* _ptr)
23 : ptr(_ptr)
24 {
25 }
27 // automatic destruction of the wrapped object at the
28 // end of our lifetime
29 ~scoped_ptr()
30 {
31 delete ptr;
32 }
34 inline T* get() const
35 {
36 return ptr;
37 }
39 inline operator T*()
40 {
41 return ptr;
42 }
44 inline T* operator-> ()
45 {
46 return ptr;
47 }
49 inline void reset (T* t = 0)
50 {
51 delete ptr;
52 ptr = t;
53 }
55 void swap(scoped_ptr & b)
56 {
57 std::swap(ptr, b.ptr);
58 }
60 private:
62 // encapsulated object pointer
63 T* ptr;
65 };
67 template<class T>
68 inline void swap(scoped_ptr<T> & a, scoped_ptr<T> & b)
69 {
70 a.swap(b);
71 }
73 } // end of namespace boost
75 #else
76 # error "scoped_ptr.h was already included"
77 #endif
78 #endif // __AI_BOOST_SCOPED_PTR_INCLUDED