PageRenderTime 17ms CodeModel.GetById 10ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/asio/detail/scoped_ptr.hpp

http://hadesmem.googlecode.com/
C++ Header | 81 lines | 49 code | 16 blank | 16 comment | 1 complexity | e678e053210977eebeab711267d6c6c2 MD5 | raw file
 1//
 2// detail/scoped_ptr.hpp
 3// ~~~~~~~~~~~~~~~~~~~~~
 4//
 5// Copyright (c) 2003-2011 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 BOOST_ASIO_DETAIL_SCOPED_PTR_HPP
12#define BOOST_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 <boost/asio/detail/config.hpp>
19
20#include <boost/asio/detail/push_options.hpp>
21
22namespace boost {
23namespace asio {
24namespace detail {
25
26template <typename T>
27class scoped_ptr
28{
29public:
30  // Constructor.
31  explicit scoped_ptr(T* p = 0)
32    : p_(p)
33  {
34  }
35
36  // Destructor.
37  ~scoped_ptr()
38  {
39    delete p_;
40  }
41
42  // Access.
43  T* get()
44  {
45    return p_;
46  }
47
48  // Access.
49  T* operator->()
50  {
51    return p_;
52  }
53
54  // Dereference.
55  T& operator*()
56  {
57    return *p_;
58  }
59
60  // Reset pointer.
61  void reset(T* p = 0)
62  {
63    delete p_;
64    p_ = p;
65  }
66
67private:
68  // Disallow copying and assignment.
69  scoped_ptr(const scoped_ptr&);
70  scoped_ptr& operator=(const scoped_ptr&);
71
72  T* p_;
73};
74
75} // namespace detail
76} // namespace asio
77} // namespace boost
78
79#include <boost/asio/detail/pop_options.hpp>
80
81#endif // BOOST_ASIO_DETAIL_SCOPED_PTR_HPP