null_tss_ptr.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // detail/null_tss_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 BOOST_ASIO_DETAIL_NULL_TSS_PTR_HPP
  11. #define BOOST_ASIO_DETAIL_NULL_TSS_PTR_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #if !defined(BOOST_ASIO_HAS_THREADS)
  17. #include <boost/asio/detail/noncopyable.hpp>
  18. #include <boost/asio/detail/push_options.hpp>
  19. namespace boost {
  20. namespace asio {
  21. namespace detail {
  22. template <typename T>
  23. class null_tss_ptr
  24. : private noncopyable
  25. {
  26. public:
  27. // Constructor.
  28. null_tss_ptr()
  29. : value_(0)
  30. {
  31. }
  32. // Destructor.
  33. ~null_tss_ptr()
  34. {
  35. }
  36. // Get the value.
  37. operator T*() const
  38. {
  39. return value_;
  40. }
  41. // Set the value.
  42. void operator=(T* value)
  43. {
  44. value_ = value;
  45. }
  46. private:
  47. T* value_;
  48. };
  49. } // namespace detail
  50. } // namespace asio
  51. } // namespace boost
  52. #include <boost/asio/detail/pop_options.hpp>
  53. #endif // !defined(BOOST_ASIO_HAS_THREADS)
  54. #endif // BOOST_ASIO_DETAIL_NULL_TSS_PTR_HPP