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 
13 #ifndef BOOST_CONFIG_HPP
14 #  include <boost/config.hpp>
15 #endif
16 
17 #if defined(BOOST_HAS_PRAGMA_ONCE)
18 #  pragma once
19 #endif
20 
21 #if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
22 #pragma GCC diagnostic push
23 #pragma GCC diagnostic ignored "-Wunused-result"
24 #endif
25 
26 //data
27 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME data
28 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace is_contiguous_container_detail {
29 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END   }}}
30 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 0
31 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 0
32 #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
33 
34 //back_free_capacity
35 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME back_free_capacity
36 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace back_free_capacity_detail {
37 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END   }}}
38 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 0
39 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 0
40 #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
41 
42 //#pragma GCC diagnostic ignored "-Wunused-result"
43 #if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
44 #pragma GCC diagnostic pop
45 #endif
46 
47 namespace boost {
48 namespace container {
49 namespace dtl {
50 
51 template <class Container>
52 struct is_contiguous_container
53 {
54    static const bool value =
55       boost::container::is_contiguous_container_detail::
56          has_member_function_callable_with_data<Container>::value &&
57       boost::container::is_contiguous_container_detail::
58          has_member_function_callable_with_data<const Container>::value;
59 };
60 
61 
62 template < class Container
63          , bool = boost::container::back_free_capacity_detail::
64                      has_member_function_callable_with_back_free_capacity<const Container>::value>
65 struct back_free_capacity
66 {
getboost::container::dtl::back_free_capacity67    static typename Container::size_type get(const Container &c)
68    {  return c.back_free_capacity();  }
69 };
70 
71 template < class Container>
72 struct back_free_capacity<Container, false>
73 {
getboost::container::dtl::back_free_capacity74    static typename Container::size_type get(const Container &c)
75    {  return c.capacity() - c.size();  }
76 };
77 
78 }  //namespace dtl {
79 }  //namespace container {
80 }  //namespace boost {
81 
82 #endif   //#ifndef BOOST_CONTAINER_DETAIL_IS_CONTIGUOUS_CONTAINER_HPP
83