null_tss_ptr.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // null_tss_ptr.hpp
  3. // ~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2008 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/push_options.hpp>
  16. #include <boost/asio/detail/push_options.hpp>
  17. #include <boost/config.hpp>
  18. #include <boost/asio/detail/pop_options.hpp>
  19. #if !defined(BOOST_HAS_THREADS)
  20. #include <boost/asio/detail/noncopyable.hpp>
  21. namespace boost {
  22. namespace asio {
  23. namespace detail {
  24. template <typename T>
  25. class null_tss_ptr
  26. : private noncopyable
  27. {
  28. public:
  29. // Constructor.
  30. null_tss_ptr()
  31. : value_(0)
  32. {
  33. }
  34. // Destructor.
  35. ~null_tss_ptr()
  36. {
  37. }
  38. // Get the value.
  39. operator T*() const
  40. {
  41. return value_;
  42. }
  43. // Set the value.
  44. void operator=(T* value)
  45. {
  46. value_ = value;
  47. }
  48. private:
  49. T* value_;
  50. };
  51. } // namespace detail
  52. } // namespace asio
  53. } // namespace boost
  54. #endif // !defined(BOOST_HAS_THREADS)
  55. #include <boost/asio/detail/pop_options.hpp>
  56. #endif // BOOST_ASIO_DETAIL_NULL_TSS_PTR_HPP