tss_ptr.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // 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_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/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/null_tss_ptr.hpp>
  21. #elif defined(BOOST_WINDOWS)
  22. # include <boost/asio/detail/win_tss_ptr.hpp>
  23. #elif defined(BOOST_HAS_PTHREADS)
  24. # include <boost/asio/detail/posix_tss_ptr.hpp>
  25. #else
  26. # error Only Windows and POSIX are supported!
  27. #endif
  28. namespace boost {
  29. namespace asio {
  30. namespace detail {
  31. template <typename T>
  32. class tss_ptr
  33. #if !defined(BOOST_HAS_THREADS)
  34. : public null_tss_ptr<T>
  35. #elif defined(BOOST_WINDOWS)
  36. : public win_tss_ptr<T>
  37. #elif defined(BOOST_HAS_PTHREADS)
  38. : public posix_tss_ptr<T>
  39. #endif
  40. {
  41. public:
  42. void operator=(T* value)
  43. {
  44. #if !defined(BOOST_HAS_THREADS)
  45. null_tss_ptr<T>::operator=(value);
  46. #elif defined(BOOST_WINDOWS)
  47. win_tss_ptr<T>::operator=(value);
  48. #elif defined(BOOST_HAS_PTHREADS)
  49. posix_tss_ptr<T>::operator=(value);
  50. #endif
  51. }
  52. };
  53. } // namespace detail
  54. } // namespace asio
  55. } // namespace boost
  56. #include <boost/asio/detail/pop_options.hpp>
  57. #endif // BOOST_ASIO_DETAIL_TSS_PTR_HPP