os/ossrv/ossrv_pub/boost_apis/boost/range/detail/common.hpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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_COMMON_HPP
sl@0
    12
#define BOOST_RANGE_DETAIL_COMMON_HPP
sl@0
    13
sl@0
    14
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
sl@0
    15
# pragma once
sl@0
    16
#endif
sl@0
    17
sl@0
    18
#include <boost/range/config.hpp>
sl@0
    19
#include <boost/range/detail/sfinae.hpp>
sl@0
    20
#include <boost/type_traits/is_void.hpp>
sl@0
    21
#include <boost/type_traits/detail/ice_or.hpp>
sl@0
    22
#include <boost/mpl/if.hpp>
sl@0
    23
#include <boost/mpl/int.hpp>
sl@0
    24
#include <cstddef>
sl@0
    25
sl@0
    26
//////////////////////////////////////////////////////////////////////////////
sl@0
    27
// missing partial specialization  workaround.
sl@0
    28
//////////////////////////////////////////////////////////////////////////////
sl@0
    29
sl@0
    30
namespace boost 
sl@0
    31
{
sl@0
    32
    namespace range_detail 
sl@0
    33
    {        
sl@0
    34
        // 1 = std containers
sl@0
    35
        // 2 = std::pair
sl@0
    36
        // 3 = const std::pair
sl@0
    37
        // 4 = array
sl@0
    38
        // 5 = const array
sl@0
    39
        // 6 = char array
sl@0
    40
        // 7 = wchar_t array
sl@0
    41
        // 8 = char*
sl@0
    42
        // 9 = const char*
sl@0
    43
        // 10 = whar_t*
sl@0
    44
        // 11 = const wchar_t*
sl@0
    45
        // 12 = string
sl@0
    46
        
sl@0
    47
        typedef mpl::int_<1>::type    std_container_;
sl@0
    48
        typedef mpl::int_<2>::type    std_pair_;
sl@0
    49
        typedef mpl::int_<3>::type    const_std_pair_;
sl@0
    50
        typedef mpl::int_<4>::type    array_;
sl@0
    51
        typedef mpl::int_<5>::type    const_array_;
sl@0
    52
        typedef mpl::int_<6>::type    char_array_;
sl@0
    53
        typedef mpl::int_<7>::type    wchar_t_array_;
sl@0
    54
        typedef mpl::int_<8>::type    char_ptr_;
sl@0
    55
        typedef mpl::int_<9>::type    const_char_ptr_;
sl@0
    56
        typedef mpl::int_<10>::type   wchar_t_ptr_;
sl@0
    57
        typedef mpl::int_<11>::type   const_wchar_t_ptr_;
sl@0
    58
        typedef mpl::int_<12>::type   string_;
sl@0
    59
        
sl@0
    60
        template< typename C >
sl@0
    61
        struct range_helper
sl@0
    62
        {
sl@0
    63
            static C* c;
sl@0
    64
            static C  ptr;
sl@0
    65
sl@0
    66
            BOOST_STATIC_CONSTANT( bool, is_pair_                = sizeof( boost::range_detail::is_pair_impl( c ) ) == sizeof( yes_type ) );
sl@0
    67
            BOOST_STATIC_CONSTANT( bool, is_char_ptr_            = sizeof( boost::range_detail::is_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
sl@0
    68
            BOOST_STATIC_CONSTANT( bool, is_const_char_ptr_      = sizeof( boost::range_detail::is_const_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
sl@0
    69
            BOOST_STATIC_CONSTANT( bool, is_wchar_t_ptr_         = sizeof( boost::range_detail::is_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
sl@0
    70
            BOOST_STATIC_CONSTANT( bool, is_const_wchar_t_ptr_   = sizeof( boost::range_detail::is_const_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
sl@0
    71
            BOOST_STATIC_CONSTANT( bool, is_char_array_          = sizeof( boost::range_detail::is_char_array_impl( ptr ) ) == sizeof( yes_type ) );
sl@0
    72
            BOOST_STATIC_CONSTANT( bool, is_wchar_t_array_       = sizeof( boost::range_detail::is_wchar_t_array_impl( ptr ) ) == sizeof( yes_type ) );
sl@0
    73
            BOOST_STATIC_CONSTANT( bool, is_string_              = (boost::type_traits::ice_or<is_const_char_ptr_, is_const_wchar_t_ptr_>::value ));
sl@0
    74
            BOOST_STATIC_CONSTANT( bool, is_array_               = boost::is_array<C>::value );
sl@0
    75
            
sl@0
    76
        };
sl@0
    77
        
sl@0
    78
        template< typename C >
sl@0
    79
        class range
sl@0
    80
        {
sl@0
    81
            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_pair_,
sl@0
    82
                                                                  boost::range_detail::std_pair_,
sl@0
    83
                                                                  void >::type pair_t;
sl@0
    84
            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_array_,
sl@0
    85
                                                                    boost::range_detail::array_,
sl@0
    86
                                                                    pair_t >::type array_t;
sl@0
    87
            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_string_,
sl@0
    88
                                                                    boost::range_detail::string_,
sl@0
    89
                                                                    array_t >::type string_t;
sl@0
    90
            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_const_char_ptr_,
sl@0
    91
                                                                    boost::range_detail::const_char_ptr_,
sl@0
    92
                                                                    string_t >::type const_char_ptr_t;
sl@0
    93
            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_char_ptr_,
sl@0
    94
                                                                    boost::range_detail::char_ptr_,
sl@0
    95
                                                                    const_char_ptr_t >::type char_ptr_t;
sl@0
    96
            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_const_wchar_t_ptr_,
sl@0
    97
                                                                    boost::range_detail::const_wchar_t_ptr_,
sl@0
    98
                                                                    char_ptr_t >::type const_wchar_ptr_t;
sl@0
    99
            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_wchar_t_ptr_,
sl@0
   100
                                                                    boost::range_detail::wchar_t_ptr_,
sl@0
   101
                                                                    const_wchar_ptr_t >::type wchar_ptr_t;
sl@0
   102
            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_wchar_t_array_,
sl@0
   103
                                                                    boost::range_detail::wchar_t_array_,
sl@0
   104
                                                                    wchar_ptr_t >::type wchar_array_t;
sl@0
   105
            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_char_array_,
sl@0
   106
                                                                    boost::range_detail::char_array_,
sl@0
   107
                                                                    wchar_array_t >::type char_array_t;
sl@0
   108
        public:
sl@0
   109
            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::is_void<char_array_t>::value,
sl@0
   110
                                                                    boost::range_detail::std_container_,
sl@0
   111
                                                                    char_array_t >::type type;  
sl@0
   112
        }; // class 'range' 
sl@0
   113
    }
sl@0
   114
}
sl@0
   115
        
sl@0
   116
#endif