]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/range/include/boost/range/detail/implementation_help.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / range / include / boost / range / detail / implementation_help.hpp
1 // Boost.Range library
2 //
3 // Copyright Thorsten Ottosen 2003-2004. Use, modification and
4 // distribution is subject to the Boost Software License, Version
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 // For more information, see http://www.boost.org/libs/range/
9 //
10
11 #ifndef BOOST_RANGE_DETAIL_IMPLEMENTATION_HELP_HPP
12 #define BOOST_RANGE_DETAIL_IMPLEMENTATION_HELP_HPP
13
14 #include <boost/range/config.hpp>
15 #include <boost/range/detail/common.hpp>
16 #include <boost/type_traits/is_same.hpp>
17 #include <cstddef>
18 #include <string.h>
19
20 #ifndef BOOST_NO_CWCHAR
21 #include <wchar.h>
22 #endif
23
24 namespace boost
25 {
26 namespace range_detail
27 {
28 template <typename T>
29 inline void boost_range_silence_warning( const T& ) { }
30
31 /////////////////////////////////////////////////////////////////////
32 // end() help
33 /////////////////////////////////////////////////////////////////////
34
35 inline const char* str_end( const char* s, const char* )
36 {
37 return s + strlen( s );
38 }
39
40 #ifndef BOOST_NO_CWCHAR
41 inline const wchar_t* str_end( const wchar_t* s, const wchar_t* )
42 {
43 return s + wcslen( s );
44 }
45 #else
46 inline const wchar_t* str_end( const wchar_t* s, const wchar_t* )
47 {
48 if( s == 0 || s[0] == 0 )
49 return s;
50 while( *++s != 0 )
51 ;
52 return s;
53 }
54 #endif
55
56 template< class Char >
57 inline Char* str_end( Char* s )
58 {
59 return const_cast<Char*>( str_end( s, s ) );
60 }
61
62 template< class T, std::size_t sz >
63 inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz] )
64 {
65 return boost_range_array + sz;
66 }
67
68 template< class T, std::size_t sz >
69 inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] )
70 {
71 return boost_range_array + sz;
72 }
73
74 /////////////////////////////////////////////////////////////////////
75 // size() help
76 /////////////////////////////////////////////////////////////////////
77
78 template< class Char >
79 inline std::size_t str_size( const Char* const& s )
80 {
81 return str_end( s ) - s;
82 }
83
84 template< class T, std::size_t sz >
85 inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz] )
86 {
87 boost_range_silence_warning( boost_range_array );
88 return sz;
89 }
90
91 template< class T, std::size_t sz >
92 inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz] )
93 {
94 boost_range_silence_warning( boost_range_array );
95 return sz;
96 }
97
98 inline bool is_same_address(const void* l, const void* r)
99 {
100 return l == r;
101 }
102
103 template<class T1, class T2>
104 inline bool is_same_object(const T1& l, const T2& r)
105 {
106 return range_detail::is_same_address(&l, &r);
107 }
108
109 } // namespace 'range_detail'
110
111 } // namespace 'boost'
112
113
114 #endif