Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

scoped_ptr.hpp 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // detail/scoped_ptr.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2019 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. #ifndef ASIO_DETAIL_SCOPED_PTR_HPP
  11. #define ASIO_DETAIL_SCOPED_PTR_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #include "asio/detail/push_options.hpp"
  17. namespace asio {
  18. namespace detail {
  19. template <typename T>
  20. class scoped_ptr
  21. {
  22. public:
  23. // Constructor.
  24. explicit scoped_ptr(T* p = 0)
  25. : p_(p)
  26. {
  27. }
  28. // Destructor.
  29. ~scoped_ptr()
  30. {
  31. delete p_;
  32. }
  33. // Access.
  34. T* get()
  35. {
  36. return p_;
  37. }
  38. // Access.
  39. T* operator->()
  40. {
  41. return p_;
  42. }
  43. // Dereference.
  44. T& operator*()
  45. {
  46. return *p_;
  47. }
  48. // Reset pointer.
  49. void reset(T* p = 0)
  50. {
  51. delete p_;
  52. p_ = p;
  53. }
  54. // Release ownership of the pointer.
  55. T* release()
  56. {
  57. T* tmp = p_;
  58. p_ = 0;
  59. return tmp;
  60. }
  61. private:
  62. // Disallow copying and assignment.
  63. scoped_ptr(const scoped_ptr&);
  64. scoped_ptr& operator=(const scoped_ptr&);
  65. T* p_;
  66. };
  67. } // namespace detail
  68. } // namespace asio
  69. #include "asio/detail/pop_options.hpp"
  70. #endif // ASIO_DETAIL_SCOPED_PTR_HPP