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_DETAIL_EMPTY_HPP
sl@0: #define BOOST_RANGE_DETAIL_EMPTY_HPP
sl@0: 
sl@0: #include <boost/range/detail/common.hpp>
sl@0: 
sl@0: namespace boost 
sl@0: {
sl@0:     namespace range_detail
sl@0:     {
sl@0:         template< typename T >
sl@0:         struct range_empty;
sl@0: 
sl@0:         //////////////////////////////////////////////////////////////////////
sl@0:         // default
sl@0:         //////////////////////////////////////////////////////////////////////
sl@0:         
sl@0:         template<>
sl@0:         struct range_empty<std_container_>
sl@0:         {
sl@0:             template< typename C >
sl@0:             static bool fun( C& c )
sl@0:             {
sl@0:                 return c.empty();
sl@0:             };
sl@0:         };
sl@0:                     
sl@0:         //////////////////////////////////////////////////////////////////////
sl@0:         // pair
sl@0:         //////////////////////////////////////////////////////////////////////
sl@0:         
sl@0:         template<>
sl@0:         struct range_empty<std_pair_>
sl@0:         {
sl@0:             template< typename P >
sl@0:             static bool fun( const P& p )
sl@0:             {
sl@0:                 return p.first == p.second;
sl@0:             }
sl@0:         };
sl@0:  
sl@0:         //////////////////////////////////////////////////////////////////////
sl@0:         // array
sl@0:         //////////////////////////////////////////////////////////////////////
sl@0:         
sl@0:         template<>
sl@0:         struct range_empty<array_>
sl@0:         {
sl@0:             template< typename T, std::size_t sz >
sl@0:             static bool fun( T BOOST_ARRAY_REF[sz] )
sl@0:             {
sl@0:                 if( boost_range_array == 0 )
sl@0:                     return true;
sl@0:                 return false;
sl@0:             }
sl@0:         };
sl@0: 
sl@0:         //////////////////////////////////////////////////////////////////////
sl@0:         // string
sl@0:         //////////////////////////////////////////////////////////////////////
sl@0:         
sl@0:         template<>
sl@0:         struct range_empty<char_ptr_>
sl@0:         {
sl@0:             static bool fun( const char* s )
sl@0:             {
sl@0:                 return s == 0 || s[0] == 0;
sl@0:             }
sl@0:         };
sl@0: 
sl@0:         template<>
sl@0:         struct range_empty<const_char_ptr_>
sl@0:         {
sl@0:             static bool fun( const char* s )
sl@0:             {
sl@0:                 return  s == 0 || s[0] == 0;
sl@0:             }
sl@0:         };
sl@0: 
sl@0:         template<>
sl@0:         struct range_empty<wchar_t_ptr_>
sl@0:         {
sl@0:             static bool fun( const wchar_t* s )
sl@0:             {
sl@0:                 return  s == 0 || s[0] == 0;
sl@0:             }
sl@0:         };
sl@0:         
sl@0:         template<>
sl@0:         struct range_empty<const_wchar_t_ptr_>
sl@0:         {
sl@0:             static bool fun( const wchar_t* s )
sl@0:             {
sl@0:                 return  s == 0 || s[0] == 0;
sl@0:             }
sl@0:         };
sl@0: 
sl@0:     } // namespace 'range_detail'
sl@0:     
sl@0:         
sl@0:     template< typename C >
sl@0:     inline bool 
sl@0:     empty( const C& c )
sl@0:     {
sl@0:         return range_detail::range_empty<  BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
sl@0:     }
sl@0: 
sl@0: } // namespace 'boost'
sl@0: 
sl@0: 
sl@0: #endif