keyword_tss_ptr.hpp 1.3 KB

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