keyword_tss_ptr.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // detail/keyword_tss_ptr.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2018 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_KEYWORD_TSS_PTR_HPP
  11. #define BOOST_ASIO_DETAIL_KEYWORD_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_THREAD_KEYWORD_EXTENSION)
  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 keyword_tss_ptr
  24. : private noncopyable
  25. {
  26. public:
  27. // Constructor.
  28. keyword_tss_ptr()
  29. {
  30. }
  31. // Destructor.
  32. ~keyword_tss_ptr()
  33. {
  34. }
  35. // Get the value.
  36. operator T*() const
  37. {
  38. return value_;
  39. }
  40. // Set the value.
  41. void operator=(T* value)
  42. {
  43. value_ = value;
  44. }
  45. private:
  46. static BOOST_ASIO_THREAD_KEYWORD T* value_;
  47. };
  48. template <typename T>
  49. BOOST_ASIO_THREAD_KEYWORD T* keyword_tss_ptr<T>::value_;
  50. } // namespace detail
  51. } // namespace asio
  52. } // namespace boost
  53. #include <boost/asio/detail/pop_options.hpp>
  54. #endif // defined(BOOST_ASIO_HAS_THREAD_KEYWORD_EXTENSION)
  55. #endif // BOOST_ASIO_DETAIL_KEYWORD_TSS_PTR_HPP