pointer_type.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2005-2012.
  4. // (C) Copyright Gennaro Prota 2003 - 2004.
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // See http://www.boost.org/libs/interprocess for documentation.
  11. //
  12. //////////////////////////////////////////////////////////////////////////////
  13. #ifndef BOOST_INTERPROCESS_DETAIL_POINTER_TYPE_HPP
  14. #define BOOST_INTERPROCESS_DETAIL_POINTER_TYPE_HPP
  15. #ifndef BOOST_CONFIG_HPP
  16. # include <boost/config.hpp>
  17. #endif
  18. #
  19. #if defined(BOOST_HAS_PRAGMA_ONCE)
  20. # pragma once
  21. #endif
  22. #include <boost/interprocess/detail/config_begin.hpp>
  23. #include <boost/interprocess/detail/workaround.hpp>
  24. #include <boost/interprocess/detail/type_traits.hpp>
  25. namespace boost {
  26. namespace interprocess {
  27. namespace ipcdetail {
  28. struct two {char _[2];};
  29. namespace pointer_type_imp {
  30. template <class U> static two test(...);
  31. template <class U> static char test(typename U::pointer* = 0);
  32. } //namespace pointer_type_imp {
  33. template <class T>
  34. struct has_pointer_type
  35. {
  36. static const bool value = sizeof(pointer_type_imp::test<T>(0)) == 1;
  37. };
  38. namespace pointer_type_imp {
  39. template <class T, class D, bool = has_pointer_type<D>::value>
  40. struct pointer_type
  41. {
  42. typedef typename D::pointer type;
  43. };
  44. template <class T, class D>
  45. struct pointer_type<T, D, false>
  46. {
  47. typedef T* type;
  48. };
  49. } //namespace pointer_type_imp {
  50. template <class T, class D>
  51. struct pointer_type
  52. {
  53. typedef typename pointer_type_imp::pointer_type<T,
  54. typename remove_reference<D>::type>::type type;
  55. };
  56. } //namespace ipcdetail {
  57. } //namespace interprocess {
  58. } //namespace boost {
  59. #include <boost/interprocess/detail/config_end.hpp>
  60. #endif //#ifndef BOOST_INTERPROCESS_DETAIL_POINTER_TYPE_HPP