Files
boost_range/include/boost/range/end.hpp

191 lines
5.1 KiB
C++
Raw Normal View History

2004-06-29 02:50:07 +00:00
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_END_HPP
#define BOOST_RANGE_END_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#include <boost/range/detail/end.hpp>
#else
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/iterator.hpp>
#include <boost/range/const_iterator.hpp>
namespace boost
2005-03-24 11:23:04 +00:00
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
2004-08-16 22:07:07 +00:00
namespace range_detail
2004-06-29 02:50:07 +00:00
{
2005-03-24 11:23:04 +00:00
#endif
2004-06-29 02:50:07 +00:00
//////////////////////////////////////////////////////////////////////
2004-08-10 16:05:53 +00:00
// primary template
2004-06-29 02:50:07 +00:00
//////////////////////////////////////////////////////////////////////
template< typename C >
2004-08-16 22:07:07 +00:00
inline BOOST_DEDUCED_TYPENAME range_const_iterator<C>::type
2005-03-24 11:23:04 +00:00
boost_range_end( const C& c )
2004-06-29 02:50:07 +00:00
{
return c.end();
}
template< typename C >
2004-08-16 22:07:07 +00:00
inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
2005-03-24 11:23:04 +00:00
boost_range_end( C& c )
2004-06-29 02:50:07 +00:00
{
return c.end();
}
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
2005-03-24 11:23:04 +00:00
inline Iterator boost_range_end( const std::pair<Iterator,Iterator>& p )
2004-06-29 02:50:07 +00:00
{
return p.second;
}
template< typename Iterator >
2005-03-24 11:23:04 +00:00
inline Iterator boost_range_end( std::pair<Iterator,Iterator>& p )
2004-06-29 02:50:07 +00:00
{
return p.second;
}
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
2005-03-24 11:23:04 +00:00
inline const T* boost_range_end( const T (&array)[sz] )
2004-06-29 02:50:07 +00:00
{
2004-07-30 21:15:29 +00:00
return range_detail::array_end<T,sz>( array );
2004-06-29 02:50:07 +00:00
}
template< typename T, std::size_t sz >
2005-03-24 11:23:04 +00:00
inline T* boost_range_end( T (&array)[sz] )
2004-06-29 02:50:07 +00:00
{
2004-07-27 13:37:44 +00:00
return range_detail::array_end<T,sz>( array );
2004-06-29 02:50:07 +00:00
}
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
2004-09-22 15:24:23 +00:00
2005-01-20 22:33:25 +00:00
#if 1 || BOOST_WORKAROUND(__MWERKS__, <= 0x3204 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
2004-09-26 12:15:12 +00:00
// CW up to 9.3 and borland have troubles with function ordering
2005-03-24 11:23:04 +00:00
inline char* boost_range_end( char* s )
2004-09-22 15:24:23 +00:00
{
return range_detail::str_end( s );
}
2005-03-24 11:23:04 +00:00
inline wchar_t* boost_range_end( wchar_t* s )
2004-09-22 15:24:23 +00:00
{
return range_detail::str_end( s );
}
2005-03-24 11:23:04 +00:00
inline const char* boost_range_end( const char* s )
2004-09-22 15:24:23 +00:00
{
return range_detail::str_end( s );
}
2005-03-24 11:23:04 +00:00
inline const wchar_t* boost_range_end( const wchar_t* s )
2004-09-22 15:24:23 +00:00
{
return range_detail::str_end( s );
}
#else
2005-03-24 11:23:04 +00:00
inline char* boost_range_end( char*& s )
2004-06-29 02:50:07 +00:00
{
return range_detail::str_end( s );
}
2005-03-24 11:23:04 +00:00
inline wchar_t* boost_range_end( wchar_t*& s )
2004-06-29 02:50:07 +00:00
{
return range_detail::str_end( s );
}
2005-03-24 11:23:04 +00:00
inline const char* boost_range_end( const char*& s )
2004-06-29 02:50:07 +00:00
{
return range_detail::str_end( s );
}
2005-03-24 11:23:04 +00:00
inline const wchar_t* boost_range_end( const wchar_t*& s )
2004-06-29 02:50:07 +00:00
{
return range_detail::str_end( s );
}
2004-09-22 15:24:23 +00:00
#endif
2005-03-24 11:23:04 +00:00
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
2004-08-16 22:07:07 +00:00
} // namespace 'range_detail'
2005-03-24 11:23:04 +00:00
#endif
2004-06-29 02:50:07 +00:00
2004-08-10 16:05:53 +00:00
template< class T >
2004-08-16 22:07:07 +00:00
inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type end( T& r )
2004-08-10 16:05:53 +00:00
{
2005-03-24 11:23:04 +00:00
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
using namespace range_detail;
#endif
return boost_range_end( r );
2004-08-10 16:05:53 +00:00
}
template< class T >
2004-08-16 22:07:07 +00:00
inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type end( const T& r )
2004-08-10 16:05:53 +00:00
{
2005-03-24 11:23:04 +00:00
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
using namespace range_detail;
#endif
return boost_range_end( r );
2004-08-10 16:05:53 +00:00
}
2004-06-29 02:50:07 +00:00
2004-09-02 17:28:57 +00:00
2004-09-16 18:27:51 +00:00
2005-01-05 18:19:31 +00:00
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
2004-09-26 13:13:04 +00:00
// BCB and CW are not able to overload pointer when class overloads are also available.
2004-09-02 17:28:57 +00:00
template<>
inline range_const_iterator<const char*>::type end<const char*>( const char*& r )
{
return range_detail::str_end( r );
}
template<>
inline range_const_iterator<const wchar_t*>::type end<const wchar_t*>( const wchar_t*& r )
{
return range_detail::str_end( r );
}
#endif
2004-06-29 02:50:07 +00:00
} // namespace 'boost'
2004-09-02 17:28:57 +00:00
2004-06-29 02:50:07 +00:00
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
2004-09-16 18:21:42 +00:00
namespace boost
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type
const_end( const T& r )
{
2005-03-24 11:23:04 +00:00
return boost::end( r );
2004-09-16 18:21:42 +00:00
}
}
2004-06-29 02:50:07 +00:00
#endif