1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #ifndef BOOST_ASIO_DETAIL_SCOPED_PTR_HPP
- #define BOOST_ASIO_DETAIL_SCOPED_PTR_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/asio/detail/config.hpp>
- #include <boost/asio/detail/push_options.hpp>
- namespace boost {
- namespace asio {
- namespace detail {
- template <typename T>
- class scoped_ptr
- {
- public:
-
- explicit scoped_ptr(T* p = 0)
- : p_(p)
- {
- }
-
- ~scoped_ptr()
- {
- delete p_;
- }
-
- T* get()
- {
- return p_;
- }
-
- T* operator->()
- {
- return p_;
- }
-
- T& operator*()
- {
- return *p_;
- }
-
- void reset(T* p = 0)
- {
- delete p_;
- p_ = p;
- }
-
- T* release()
- {
- T* tmp = p_;
- p_ = 0;
- return tmp;
- }
- private:
-
- scoped_ptr(const scoped_ptr&);
- scoped_ptr& operator=(const scoped_ptr&);
- T* p_;
- };
- }
- }
- }
- #include <boost/asio/detail/pop_options.hpp>
- #endif
|