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

144 lines
3.9 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_DETAIL_END_HPP
#define BOOST_RANGE_DETAIL_END_HPP
#include <boost/range/detail/implementation_help.hpp>
2004-07-02 10:30:36 +00:00
#include <boost/range/result_iterator.hpp>
2004-06-29 02:50:07 +00:00
#include <boost/range/detail/common.hpp>
namespace boost
{
namespace range_detail
{
template< typename T >
2004-07-23 14:00:36 +00:00
struct range_end;
2004-06-29 02:50:07 +00:00
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
2004-07-23 14:00:36 +00:00
struct range_end<std_container_>
2004-06-29 02:50:07 +00:00
{
template< typename C >
2004-08-16 22:07:07 +00:00
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type
fun( C& c )
2004-06-29 02:50:07 +00:00
{
return c.end();
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
2004-07-23 14:00:36 +00:00
struct range_end<std_pair_>
2004-06-29 02:50:07 +00:00
{
template< typename P >
2004-08-16 22:07:07 +00:00
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<P>::type
fun( const P& p )
2004-06-29 02:50:07 +00:00
{
return p.second;
}
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template<>
2004-07-23 14:00:36 +00:00
struct range_end<array_>
2004-06-29 02:50:07 +00:00
{
template< typename T, std::size_t sz >
2004-07-23 14:00:36 +00:00
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
2004-06-29 02:50:07 +00:00
{
return boost::range_detail::array_end( array );
}
};
template<>
2004-07-23 14:00:36 +00:00
struct range_end<char_array_>
2004-06-29 02:50:07 +00:00
{
template< typename T, std::size_t sz >
2004-07-23 14:00:36 +00:00
static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
2004-06-29 02:50:07 +00:00
{
return boost::range_detail::array_end( array );
}
};
template<>
2004-07-23 14:00:36 +00:00
struct range_end<wchar_t_array_>
2004-06-29 02:50:07 +00:00
{
template< typename T, std::size_t sz >
2004-07-23 14:00:36 +00:00
static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
2004-06-29 02:50:07 +00:00
{
return boost::range_detail::array_end( array );
}
};
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
template<>
2004-07-23 14:00:36 +00:00
struct range_end<char_ptr_>
2004-06-29 02:50:07 +00:00
{
static char* fun( char* s )
{
return boost::range_detail::str_end( s );
}
};
template<>
2004-07-23 14:00:36 +00:00
struct range_end<const_char_ptr_>
2004-06-29 02:50:07 +00:00
{
static const char* fun( const char* s )
{
return boost::range_detail::str_end( s );
}
};
template<>
2004-07-23 14:00:36 +00:00
struct range_end<wchar_t_ptr_>
2004-06-29 02:50:07 +00:00
{
static wchar_t* fun( wchar_t* s )
{
return boost::range_detail::str_end( s );
}
};
template<>
2004-07-23 14:00:36 +00:00
struct range_end<const_wchar_t_ptr_>
2004-06-29 02:50:07 +00:00
{
static const wchar_t* fun( const wchar_t* s )
{
return boost::range_detail::str_end( s );
}
};
} // namespace 'range_detail'
template< typename C >
2004-08-16 22:07:07 +00:00
inline BOOST_DEDUCED_TYPENAME range_result_iterator<C>::type
2004-06-29 02:50:07 +00:00
end( C& c )
{
2004-08-16 22:07:07 +00:00
return range_detail::range_end< BOOST_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
2004-06-29 02:50:07 +00:00
}
} // namespace 'boost'
#endif