File indexing completed on 2025-01-18 09:51:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_RANGE_DETAIL_COMMON_HPP
0012 #define BOOST_RANGE_DETAIL_COMMON_HPP
0013
0014 #if defined(_MSC_VER)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/range/config.hpp>
0019 #include <boost/range/detail/sfinae.hpp>
0020 #include <boost/type_traits/is_void.hpp>
0021 #include <boost/mpl/if.hpp>
0022 #include <boost/mpl/int.hpp>
0023 #include <cstddef>
0024
0025
0026
0027
0028
0029 namespace boost
0030 {
0031 namespace range_detail
0032 {
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 typedef mpl::int_<1>::type std_container_;
0047 typedef mpl::int_<2>::type std_pair_;
0048 typedef mpl::int_<3>::type const_std_pair_;
0049 typedef mpl::int_<4>::type array_;
0050 typedef mpl::int_<5>::type const_array_;
0051 typedef mpl::int_<6>::type char_array_;
0052 typedef mpl::int_<7>::type wchar_t_array_;
0053 typedef mpl::int_<8>::type char_ptr_;
0054 typedef mpl::int_<9>::type const_char_ptr_;
0055 typedef mpl::int_<10>::type wchar_t_ptr_;
0056 typedef mpl::int_<11>::type const_wchar_t_ptr_;
0057 typedef mpl::int_<12>::type string_;
0058
0059 template< typename C >
0060 struct range_helper
0061 {
0062 static C* c;
0063 static C ptr;
0064
0065 BOOST_STATIC_CONSTANT( bool, is_pair_ = sizeof( boost::range_detail::is_pair_impl( c ) ) == sizeof( yes_type ) );
0066 BOOST_STATIC_CONSTANT( bool, is_char_ptr_ = sizeof( boost::range_detail::is_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
0067 BOOST_STATIC_CONSTANT( bool, is_const_char_ptr_ = sizeof( boost::range_detail::is_const_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
0068 BOOST_STATIC_CONSTANT( bool, is_wchar_t_ptr_ = sizeof( boost::range_detail::is_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
0069 BOOST_STATIC_CONSTANT( bool, is_const_wchar_t_ptr_ = sizeof( boost::range_detail::is_const_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
0070 BOOST_STATIC_CONSTANT( bool, is_char_array_ = sizeof( boost::range_detail::is_char_array_impl( ptr ) ) == sizeof( yes_type ) );
0071 BOOST_STATIC_CONSTANT( bool, is_wchar_t_array_ = sizeof( boost::range_detail::is_wchar_t_array_impl( ptr ) ) == sizeof( yes_type ) );
0072 BOOST_STATIC_CONSTANT( bool, is_string_ = (is_const_char_ptr_ || is_const_wchar_t_ptr_));
0073 BOOST_STATIC_CONSTANT( bool, is_array_ = boost::is_array<C>::value );
0074
0075 };
0076
0077 template< typename C >
0078 class range
0079 {
0080 typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_pair_,
0081 boost::range_detail::std_pair_,
0082 void >::type pair_t;
0083 typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_array_,
0084 boost::range_detail::array_,
0085 pair_t >::type array_t;
0086 typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_string_,
0087 boost::range_detail::string_,
0088 array_t >::type string_t;
0089 typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_const_char_ptr_,
0090 boost::range_detail::const_char_ptr_,
0091 string_t >::type const_char_ptr_t;
0092 typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_char_ptr_,
0093 boost::range_detail::char_ptr_,
0094 const_char_ptr_t >::type char_ptr_t;
0095 typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_const_wchar_t_ptr_,
0096 boost::range_detail::const_wchar_t_ptr_,
0097 char_ptr_t >::type const_wchar_ptr_t;
0098 typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_wchar_t_ptr_,
0099 boost::range_detail::wchar_t_ptr_,
0100 const_wchar_ptr_t >::type wchar_ptr_t;
0101 typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_wchar_t_array_,
0102 boost::range_detail::wchar_t_array_,
0103 wchar_ptr_t >::type wchar_array_t;
0104 typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_char_array_,
0105 boost::range_detail::char_array_,
0106 wchar_array_t >::type char_array_t;
0107 public:
0108 typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::is_void<char_array_t>::value,
0109 boost::range_detail::std_container_,
0110 char_array_t >::type type;
0111 };
0112 }
0113 }
0114
0115 #endif
0116