author | sl |
Tue, 10 Jun 2014 14:32:02 +0200 | |
changeset 1 | 260cb5ec6c19 |
permissions | -rw-r--r-- |
sl@0 | 1 |
// Boost.Range library |
sl@0 | 2 |
// |
sl@0 | 3 |
// Copyright Thorsten Ottosen 2003-2004. Use, modification and |
sl@0 | 4 |
// distribution is subject to the Boost Software License, Version |
sl@0 | 5 |
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
sl@0 | 6 |
// http://www.boost.org/LICENSE_1_0.txt) |
sl@0 | 7 |
// |
sl@0 | 8 |
// For more information, see http://www.boost.org/libs/range/ |
sl@0 | 9 |
// |
sl@0 | 10 |
|
sl@0 | 11 |
#ifndef BOOST_RANGE_DETAIL_EMPTY_HPP |
sl@0 | 12 |
#define BOOST_RANGE_DETAIL_EMPTY_HPP |
sl@0 | 13 |
|
sl@0 | 14 |
#include <boost/range/detail/common.hpp> |
sl@0 | 15 |
|
sl@0 | 16 |
namespace boost |
sl@0 | 17 |
{ |
sl@0 | 18 |
namespace range_detail |
sl@0 | 19 |
{ |
sl@0 | 20 |
template< typename T > |
sl@0 | 21 |
struct range_empty; |
sl@0 | 22 |
|
sl@0 | 23 |
////////////////////////////////////////////////////////////////////// |
sl@0 | 24 |
// default |
sl@0 | 25 |
////////////////////////////////////////////////////////////////////// |
sl@0 | 26 |
|
sl@0 | 27 |
template<> |
sl@0 | 28 |
struct range_empty<std_container_> |
sl@0 | 29 |
{ |
sl@0 | 30 |
template< typename C > |
sl@0 | 31 |
static bool fun( C& c ) |
sl@0 | 32 |
{ |
sl@0 | 33 |
return c.empty(); |
sl@0 | 34 |
}; |
sl@0 | 35 |
}; |
sl@0 | 36 |
|
sl@0 | 37 |
////////////////////////////////////////////////////////////////////// |
sl@0 | 38 |
// pair |
sl@0 | 39 |
////////////////////////////////////////////////////////////////////// |
sl@0 | 40 |
|
sl@0 | 41 |
template<> |
sl@0 | 42 |
struct range_empty<std_pair_> |
sl@0 | 43 |
{ |
sl@0 | 44 |
template< typename P > |
sl@0 | 45 |
static bool fun( const P& p ) |
sl@0 | 46 |
{ |
sl@0 | 47 |
return p.first == p.second; |
sl@0 | 48 |
} |
sl@0 | 49 |
}; |
sl@0 | 50 |
|
sl@0 | 51 |
////////////////////////////////////////////////////////////////////// |
sl@0 | 52 |
// array |
sl@0 | 53 |
////////////////////////////////////////////////////////////////////// |
sl@0 | 54 |
|
sl@0 | 55 |
template<> |
sl@0 | 56 |
struct range_empty<array_> |
sl@0 | 57 |
{ |
sl@0 | 58 |
template< typename T, std::size_t sz > |
sl@0 | 59 |
static bool fun( T BOOST_ARRAY_REF[sz] ) |
sl@0 | 60 |
{ |
sl@0 | 61 |
if( boost_range_array == 0 ) |
sl@0 | 62 |
return true; |
sl@0 | 63 |
return false; |
sl@0 | 64 |
} |
sl@0 | 65 |
}; |
sl@0 | 66 |
|
sl@0 | 67 |
////////////////////////////////////////////////////////////////////// |
sl@0 | 68 |
// string |
sl@0 | 69 |
////////////////////////////////////////////////////////////////////// |
sl@0 | 70 |
|
sl@0 | 71 |
template<> |
sl@0 | 72 |
struct range_empty<char_ptr_> |
sl@0 | 73 |
{ |
sl@0 | 74 |
static bool fun( const char* s ) |
sl@0 | 75 |
{ |
sl@0 | 76 |
return s == 0 || s[0] == 0; |
sl@0 | 77 |
} |
sl@0 | 78 |
}; |
sl@0 | 79 |
|
sl@0 | 80 |
template<> |
sl@0 | 81 |
struct range_empty<const_char_ptr_> |
sl@0 | 82 |
{ |
sl@0 | 83 |
static bool fun( const char* s ) |
sl@0 | 84 |
{ |
sl@0 | 85 |
return s == 0 || s[0] == 0; |
sl@0 | 86 |
} |
sl@0 | 87 |
}; |
sl@0 | 88 |
|
sl@0 | 89 |
template<> |
sl@0 | 90 |
struct range_empty<wchar_t_ptr_> |
sl@0 | 91 |
{ |
sl@0 | 92 |
static bool fun( const wchar_t* s ) |
sl@0 | 93 |
{ |
sl@0 | 94 |
return s == 0 || s[0] == 0; |
sl@0 | 95 |
} |
sl@0 | 96 |
}; |
sl@0 | 97 |
|
sl@0 | 98 |
template<> |
sl@0 | 99 |
struct range_empty<const_wchar_t_ptr_> |
sl@0 | 100 |
{ |
sl@0 | 101 |
static bool fun( const wchar_t* s ) |
sl@0 | 102 |
{ |
sl@0 | 103 |
return s == 0 || s[0] == 0; |
sl@0 | 104 |
} |
sl@0 | 105 |
}; |
sl@0 | 106 |
|
sl@0 | 107 |
} // namespace 'range_detail' |
sl@0 | 108 |
|
sl@0 | 109 |
|
sl@0 | 110 |
template< typename C > |
sl@0 | 111 |
inline bool |
sl@0 | 112 |
empty( const C& c ) |
sl@0 | 113 |
{ |
sl@0 | 114 |
return range_detail::range_empty< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c ); |
sl@0 | 115 |
} |
sl@0 | 116 |
|
sl@0 | 117 |
} // namespace 'boost' |
sl@0 | 118 |
|
sl@0 | 119 |
|
sl@0 | 120 |
#endif |