epoc32/include/stdapis/boost/range/size.hpp
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     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_SIZE_HPP
    12 #define BOOST_RANGE_SIZE_HPP
    13 
    14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
    15 # pragma once
    16 #endif
    17 
    18 #include <boost/range/config.hpp>
    19 
    20 #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
    21 #include <boost/range/detail/size.hpp>
    22 #else
    23 
    24 #include <boost/range/detail/implementation_help.hpp>
    25 #include <boost/range/size_type.hpp>
    26 #include <cstddef>
    27 #include <iterator>
    28 #include <utility>
    29 
    30 namespace boost 
    31 {
    32 
    33 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))    
    34 namespace range_detail 
    35 {
    36 #endif
    37         //////////////////////////////////////////////////////////////////////
    38         // primary template
    39         //////////////////////////////////////////////////////////////////////
    40         
    41         template< typename C >
    42         inline BOOST_DEDUCED_TYPENAME C::size_type
    43         boost_range_size(  const C& c )
    44         {
    45             return c.size(); 
    46         }
    47 
    48         //////////////////////////////////////////////////////////////////////
    49         // pair
    50         //////////////////////////////////////////////////////////////////////
    51 
    52         template< typename Iterator >
    53         inline std::size_t boost_range_size(  const std::pair<Iterator,Iterator>& p )
    54         {
    55             return std::distance( p.first, p.second );
    56         }
    57 
    58         //////////////////////////////////////////////////////////////////////
    59         // array
    60         //////////////////////////////////////////////////////////////////////
    61 
    62         template< typename T, std::size_t sz >
    63         inline std::size_t boost_range_size(  const T (&array)[sz] )
    64         {
    65             return range_detail::array_size<T,sz>( array ); 
    66         }
    67         
    68         template< typename T, std::size_t sz >
    69         inline std::size_t boost_range_size(  T (&array)[sz] )
    70         {
    71             return boost::range_detail::array_size<T,sz>( array );
    72         }
    73         
    74         //////////////////////////////////////////////////////////////////////
    75         // string
    76         //////////////////////////////////////////////////////////////////////
    77 
    78         inline std::size_t boost_range_size(  const char* const& s )
    79         {
    80             return boost::range_detail::str_size( s );
    81         }
    82 
    83         inline std::size_t boost_range_size(  const wchar_t* const& s )
    84         {
    85             return boost::range_detail::str_size( s );
    86         }
    87 
    88 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))                
    89 } // namespace 'range_detail'
    90 #endif
    91 
    92 template< class T >
    93 inline BOOST_DEDUCED_TYPENAME range_size<T>::type size(  const T& r )
    94 {
    95 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))        
    96     using namespace range_detail;
    97 #endif    
    98     return boost_range_size( r );
    99 }
   100 
   101 
   102 #if BOOST_WORKAROUND(__MWERKS__, <= 0x3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
   103 // BCB and CW are not able to overload pointer when class overloads are also available.
   104 inline range_size<const char*>::type size(  const char* r ) {
   105     return range_detail::str_size( r );
   106 }
   107 inline range_size<char*>::type size(  char* r ) {
   108     return range_detail::str_size( r );
   109 }
   110 inline range_size<const wchar_t*>::type size(  const wchar_t* r ) {
   111     return range_detail::str_size( r );
   112 }
   113 inline range_size<wchar_t*>::type size(  wchar_t* r ) {
   114     return range_detail::str_size( r );
   115 }
   116 #endif
   117 
   118 
   119 } // namespace 'boost'
   120 
   121 #endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
   122 
   123 #endif