tss_ptr.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // detail/tss_ptr.hpp
  3. // ~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2021 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_TSS_PTR_HPP
  11. #define BOOST_ASIO_DETAIL_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/null_tss_ptr.hpp>
  18. #elif defined(BOOST_ASIO_HAS_THREAD_KEYWORD_EXTENSION)
  19. # include <boost/asio/detail/keyword_tss_ptr.hpp>
  20. #elif defined(BOOST_ASIO_WINDOWS)
  21. # include <boost/asio/detail/win_tss_ptr.hpp>
  22. #elif defined(BOOST_ASIO_HAS_PTHREADS)
  23. # include <boost/asio/detail/posix_tss_ptr.hpp>
  24. #else
  25. # error Only Windows and POSIX are supported!
  26. #endif
  27. #include <boost/asio/detail/push_options.hpp>
  28. namespace boost {
  29. namespace asio {
  30. namespace detail {
  31. template <typename T>
  32. class tss_ptr
  33. #if !defined(BOOST_ASIO_HAS_THREADS)
  34. : public null_tss_ptr<T>
  35. #elif defined(BOOST_ASIO_HAS_THREAD_KEYWORD_EXTENSION)
  36. : public keyword_tss_ptr<T>
  37. #elif defined(BOOST_ASIO_WINDOWS)
  38. : public win_tss_ptr<T>
  39. #elif defined(BOOST_ASIO_HAS_PTHREADS)
  40. : public posix_tss_ptr<T>
  41. #endif
  42. {
  43. public:
  44. void operator=(T* value)
  45. {
  46. #if !defined(BOOST_ASIO_HAS_THREADS)
  47. null_tss_ptr<T>::operator=(value);
  48. #elif defined(BOOST_ASIO_HAS_THREAD_KEYWORD_EXTENSION)
  49. keyword_tss_ptr<T>::operator=(value);
  50. #elif defined(BOOST_ASIO_WINDOWS)
  51. win_tss_ptr<T>::operator=(value);
  52. #elif defined(BOOST_ASIO_HAS_PTHREADS)
  53. posix_tss_ptr<T>::operator=(value);
  54. #endif
  55. }
  56. };
  57. } // namespace detail
  58. } // namespace asio
  59. } // namespace boost
  60. #include <boost/asio/detail/pop_options.hpp>
  61. #endif // BOOST_ASIO_DETAIL_TSS_PTR_HPP