Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / asio / detail / scoped_ptr.hpp @ 2486

History | View | Annotate | Download (1.3 kB)

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 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

    
22
namespace boost {
23
namespace asio {
24
namespace detail {
25

    
26
template <typename T>
27
class scoped_ptr
28
{
29
public:
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

    
67
private:
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