is_contiguous_container.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2017-2017. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/container for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #ifndef BOOST_CONTAINER_DETAIL_IS_CONTIGUOUS_CONTAINER_HPP
  11. #define BOOST_CONTAINER_DETAIL_IS_CONTIGUOUS_CONTAINER_HPP
  12. #ifndef BOOST_CONFIG_HPP
  13. # include <boost/config.hpp>
  14. #endif
  15. #if defined(BOOST_HAS_PRAGMA_ONCE)
  16. # pragma once
  17. #endif
  18. #if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
  19. #pragma GCC diagnostic push
  20. #pragma GCC diagnostic ignored "-Wunused-result"
  21. #endif
  22. //data
  23. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME data
  24. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace is_contiguous_container_detail {
  25. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}}
  26. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 0
  27. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 0
  28. #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
  29. //free_storage
  30. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME unused_storage
  31. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace unused_storage_detail {
  32. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}}
  33. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 0
  34. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 0
  35. #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
  36. //#pragma GCC diagnostic ignored "-Wunused-result"
  37. #if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
  38. #pragma GCC diagnostic pop
  39. #endif
  40. namespace boost {
  41. namespace container {
  42. namespace dtl {
  43. template <class Container>
  44. struct is_contiguous_container
  45. {
  46. BOOST_STATIC_CONSTEXPR bool value =
  47. boost::container::is_contiguous_container_detail::
  48. has_member_function_callable_with_data<Container>::value &&
  49. boost::container::is_contiguous_container_detail::
  50. has_member_function_callable_with_data<const Container>::value;
  51. };
  52. template < class Container
  53. , bool = boost::container::unused_storage_detail::
  54. has_member_function_callable_with_unused_storage<const Container>::value>
  55. struct unused_storage
  56. {
  57. static typename Container::value_type* get(Container &c, typename Container::size_type &s)
  58. { return c.unused_storage(s); }
  59. };
  60. template < class Container>
  61. struct unused_storage<Container, false>
  62. {
  63. static typename Container::value_type* get(Container&, typename Container::size_type &s)
  64. {
  65. s = 0;
  66. return 0;
  67. }
  68. };
  69. } //namespace dtl {
  70. } //namespace container {
  71. } //namespace boost {
  72. #endif //#ifndef BOOST_CONTAINER_DETAIL_IS_CONTIGUOUS_CONTAINER_HPP