is_contiguous_container.hpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. //back_free_capacity
  30. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME back_free_capacity
  31. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace back_free_capacity_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. static const 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::back_free_capacity_detail::
  54. has_member_function_callable_with_back_free_capacity<const Container>::value>
  55. struct back_free_capacity
  56. {
  57. static typename Container::size_type get(const Container &c)
  58. { return c.back_free_capacity(); }
  59. };
  60. template < class Container>
  61. struct back_free_capacity<Container, false>
  62. {
  63. static typename Container::size_type get(const Container &c)
  64. { return c.capacity() - c.size(); }
  65. };
  66. } //namespace dtl {
  67. } //namespace container {
  68. } //namespace boost {
  69. #endif //#ifndef BOOST_CONTAINER_DETAIL_IS_CONTIGUOUS_CONTAINER_HPP