sl@0: // Boost.Range library sl@0: // sl@0: // Copyright Thorsten Ottosen 2003-2004. Use, modification and sl@0: // distribution is subject to the Boost Software License, Version sl@0: // 1.0. (See accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: // sl@0: // For more information, see http://www.boost.org/libs/range/ sl@0: // sl@0: sl@0: #ifndef BOOST_RANGE_BEGIN_HPP sl@0: #define BOOST_RANGE_BEGIN_HPP sl@0: sl@0: #if defined(_MSC_VER) && (_MSC_VER >= 1200) sl@0: # pragma once sl@0: #endif sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING sl@0: #include sl@0: #else sl@0: sl@0: #include sl@0: #include sl@0: sl@0: namespace boost sl@0: { sl@0: sl@0: #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ sl@0: !BOOST_WORKAROUND(__GNUC__, < 3) \ sl@0: /**/ sl@0: namespace range_detail sl@0: { sl@0: #endif sl@0: sl@0: ////////////////////////////////////////////////////////////////////// sl@0: // primary template sl@0: ////////////////////////////////////////////////////////////////////// sl@0: sl@0: template< typename C > sl@0: inline BOOST_DEDUCED_TYPENAME range_const_iterator::type sl@0: boost_range_begin( const C& c ) sl@0: { sl@0: return c.begin(); sl@0: } sl@0: sl@0: template< typename C > sl@0: inline BOOST_DEDUCED_TYPENAME range_iterator< sl@0: typename remove_const::type >::type sl@0: boost_range_begin( C& c ) sl@0: { sl@0: return c.begin(); sl@0: } sl@0: sl@0: ////////////////////////////////////////////////////////////////////// sl@0: // pair sl@0: ////////////////////////////////////////////////////////////////////// sl@0: sl@0: template< typename Iterator > sl@0: inline Iterator boost_range_begin( const std::pair& p ) sl@0: { sl@0: return p.first; sl@0: } sl@0: sl@0: template< typename Iterator > sl@0: inline Iterator boost_range_begin( std::pair& p ) sl@0: { sl@0: return p.first; sl@0: } sl@0: sl@0: ////////////////////////////////////////////////////////////////////// sl@0: // array sl@0: ////////////////////////////////////////////////////////////////////// sl@0: sl@0: template< typename T, std::size_t sz > sl@0: inline const T* boost_range_begin( const T (&array)[sz] ) sl@0: { sl@0: return array; sl@0: } sl@0: sl@0: template< typename T, std::size_t sz > sl@0: inline T* boost_range_begin( T (&array)[sz] ) sl@0: { sl@0: return array; sl@0: } sl@0: sl@0: sl@0: ////////////////////////////////////////////////////////////////////// sl@0: // string sl@0: ////////////////////////////////////////////////////////////////////// sl@0: sl@0: #if 1 || BOOST_WORKAROUND(__MWERKS__, <= 0x3204 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) sl@0: // CW up to 9.3 and borland have troubles with function ordering sl@0: inline const char* boost_range_begin( const char* s ) sl@0: { sl@0: return s; sl@0: } sl@0: sl@0: inline char* boost_range_begin( char* s ) sl@0: { sl@0: return s; sl@0: } sl@0: sl@0: inline const wchar_t* boost_range_begin( const wchar_t* s ) sl@0: { sl@0: return s; sl@0: } sl@0: sl@0: inline wchar_t* boost_range_begin( wchar_t* s ) sl@0: { sl@0: return s; sl@0: } sl@0: #else sl@0: inline const char* boost_range_begin( const char*& s ) sl@0: { sl@0: return s; sl@0: } sl@0: sl@0: inline char* boost_range_begin( char*& s ) sl@0: { sl@0: return s; sl@0: } sl@0: sl@0: inline const wchar_t* boost_range_begin( const wchar_t*& s ) sl@0: { sl@0: return s; sl@0: } sl@0: sl@0: inline wchar_t* boost_range_begin( wchar_t*& s ) sl@0: { sl@0: return s; sl@0: } sl@0: #endif sl@0: sl@0: #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ sl@0: !BOOST_WORKAROUND(__GNUC__, < 3) \ sl@0: /**/ sl@0: } // namespace 'range_detail' sl@0: #endif sl@0: sl@0: sl@0: template< class T > sl@0: inline BOOST_DEDUCED_TYPENAME range_iterator< sl@0: typename remove_const::type >::type begin( T& r ) sl@0: { sl@0: #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ sl@0: !BOOST_WORKAROUND(__GNUC__, < 3) \ sl@0: /**/ sl@0: using namespace range_detail; sl@0: #endif sl@0: return boost_range_begin( r ); sl@0: } sl@0: sl@0: template< class T > sl@0: inline BOOST_DEDUCED_TYPENAME range_const_iterator::type begin( const T& r ) sl@0: { sl@0: #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ sl@0: !BOOST_WORKAROUND(__GNUC__, < 3) \ sl@0: /**/ sl@0: using namespace range_detail; sl@0: #endif sl@0: return boost_range_begin( r ); sl@0: } sl@0: sl@0: #if BOOST_WORKAROUND(__MWERKS__, <= 0x3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) sl@0: // BCB and CW are not able to overload pointer when class overloads are also available. sl@0: template<> sl@0: inline range_const_iterator::type begin( const char*& r ) sl@0: { sl@0: return r; sl@0: } sl@0: sl@0: template<> sl@0: inline range_const_iterator::type begin( const wchar_t*& r ) sl@0: { sl@0: return r; sl@0: } sl@0: sl@0: #endif sl@0: sl@0: } // namespace boost sl@0: sl@0: #endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING sl@0: sl@0: namespace boost sl@0: { sl@0: template< class T > sl@0: inline BOOST_DEDUCED_TYPENAME range_const_iterator::type sl@0: const_begin( const T& r ) sl@0: { sl@0: return boost::begin( r ); sl@0: } sl@0: } sl@0: sl@0: #endif