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)
8 // For more information, see http://www.boost.org/libs/range/
11 #ifndef BOOST_RANGE_BEGIN_HPP
12 #define BOOST_RANGE_BEGIN_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/type_traits/remove_const.hpp>
19 #include <boost/range/config.hpp>
21 #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
22 #include <boost/range/detail/begin.hpp>
25 #include <boost/range/iterator.hpp>
26 #include <boost/range/const_iterator.hpp>
31 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
32 !BOOST_WORKAROUND(__GNUC__, < 3) \
34 namespace range_detail
38 //////////////////////////////////////////////////////////////////////
40 //////////////////////////////////////////////////////////////////////
42 template< typename C >
43 inline BOOST_DEDUCED_TYPENAME range_const_iterator<C>::type
44 boost_range_begin( const C& c )
49 template< typename C >
50 inline BOOST_DEDUCED_TYPENAME range_iterator<
51 typename remove_const<C>::type >::type
52 boost_range_begin( C& c )
57 //////////////////////////////////////////////////////////////////////
59 //////////////////////////////////////////////////////////////////////
61 template< typename Iterator >
62 inline Iterator boost_range_begin( const std::pair<Iterator,Iterator>& p )
67 template< typename Iterator >
68 inline Iterator boost_range_begin( std::pair<Iterator,Iterator>& p )
73 //////////////////////////////////////////////////////////////////////
75 //////////////////////////////////////////////////////////////////////
77 template< typename T, std::size_t sz >
78 inline const T* boost_range_begin( const T (&array)[sz] )
83 template< typename T, std::size_t sz >
84 inline T* boost_range_begin( T (&array)[sz] )
90 //////////////////////////////////////////////////////////////////////
92 //////////////////////////////////////////////////////////////////////
94 #if 1 || BOOST_WORKAROUND(__MWERKS__, <= 0x3204 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
95 // CW up to 9.3 and borland have troubles with function ordering
96 inline const char* boost_range_begin( const char* s )
101 inline char* boost_range_begin( char* s )
106 inline const wchar_t* boost_range_begin( const wchar_t* s )
111 inline wchar_t* boost_range_begin( wchar_t* s )
116 inline const char* boost_range_begin( const char*& s )
121 inline char* boost_range_begin( char*& s )
126 inline const wchar_t* boost_range_begin( const wchar_t*& s )
131 inline wchar_t* boost_range_begin( wchar_t*& s )
137 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
138 !BOOST_WORKAROUND(__GNUC__, < 3) \
140 } // namespace 'range_detail'
145 inline BOOST_DEDUCED_TYPENAME range_iterator<
146 typename remove_const<T>::type >::type begin( T& r )
148 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
149 !BOOST_WORKAROUND(__GNUC__, < 3) \
151 using namespace range_detail;
153 return boost_range_begin( r );
157 inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type begin( const T& r )
159 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
160 !BOOST_WORKAROUND(__GNUC__, < 3) \
162 using namespace range_detail;
164 return boost_range_begin( r );
167 #if BOOST_WORKAROUND(__MWERKS__, <= 0x3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
168 // BCB and CW are not able to overload pointer when class overloads are also available.
170 inline range_const_iterator<const char*>::type begin<const char*>( const char*& r )
176 inline range_const_iterator<const wchar_t*>::type begin<const wchar_t*>( const wchar_t*& r )
185 #endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
190 inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type
191 const_begin( const T& r )
193 return boost::begin( r );