Realistic 3D camera system
3D camera system components
scoped_ptr.hpp
Go to the documentation of this file.
1 //
2 // detail/scoped_ptr.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10 
11 #ifndef ASIO_DETAIL_SCOPED_PTR_HPP
12 #define ASIO_DETAIL_SCOPED_PTR_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/config.hpp"
19 
21 
22 namespace asio {
23 namespace detail {
24 
25 template <typename T>
27 {
28 public:
29  // Constructor.
30  explicit scoped_ptr(T* p = 0)
31  : p_(p)
32  {
33  }
34 
35  // Destructor.
37  {
38  delete p_;
39  }
40 
41  // Access.
42  T* get()
43  {
44  return p_;
45  }
46 
47  // Access.
49  {
50  return p_;
51  }
52 
53  // Dereference.
54  T& operator*()
55  {
56  return *p_;
57  }
58 
59  // Reset pointer.
60  void reset(T* p = 0)
61  {
62  delete p_;
63  p_ = p;
64  }
65 
66 private:
67  // Disallow copying and assignment.
68  scoped_ptr(const scoped_ptr&);
69  scoped_ptr& operator=(const scoped_ptr&);
70 
71  T* p_;
72 };
73 
74 } // namespace detail
75 } // namespace asio
76 
78 
79 #endif // ASIO_DETAIL_SCOPED_PTR_HPP