Chris@16: // Boost.Range library Chris@16: // Chris@16: // Copyright Thorsten Ottosen 2003-2004. Use, modification and Chris@16: // distribution is subject to the Boost Software License, Version Chris@16: // 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // For more information, see http://www.boost.org/libs/range/ Chris@16: // Chris@16: Chris@16: #ifndef BOOST_RANGE_DETAIL_COMMON_HPP Chris@16: #define BOOST_RANGE_DETAIL_COMMON_HPP Chris@16: Chris@101: #if defined(_MSC_VER) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: // missing partial specialization workaround. Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: Chris@16: namespace boost Chris@16: { Chris@16: namespace range_detail Chris@16: { Chris@16: // 1 = std containers Chris@16: // 2 = std::pair Chris@16: // 3 = const std::pair Chris@16: // 4 = array Chris@16: // 5 = const array Chris@16: // 6 = char array Chris@16: // 7 = wchar_t array Chris@16: // 8 = char* Chris@16: // 9 = const char* Chris@16: // 10 = whar_t* Chris@16: // 11 = const wchar_t* Chris@16: // 12 = string Chris@16: Chris@16: typedef mpl::int_<1>::type std_container_; Chris@16: typedef mpl::int_<2>::type std_pair_; Chris@16: typedef mpl::int_<3>::type const_std_pair_; Chris@16: typedef mpl::int_<4>::type array_; Chris@16: typedef mpl::int_<5>::type const_array_; Chris@16: typedef mpl::int_<6>::type char_array_; Chris@16: typedef mpl::int_<7>::type wchar_t_array_; Chris@16: typedef mpl::int_<8>::type char_ptr_; Chris@16: typedef mpl::int_<9>::type const_char_ptr_; Chris@16: typedef mpl::int_<10>::type wchar_t_ptr_; Chris@16: typedef mpl::int_<11>::type const_wchar_t_ptr_; Chris@16: typedef mpl::int_<12>::type string_; Chris@16: Chris@16: template< typename C > Chris@16: struct range_helper Chris@16: { Chris@16: static C* c; Chris@16: static C ptr; Chris@16: Chris@16: BOOST_STATIC_CONSTANT( bool, is_pair_ = sizeof( boost::range_detail::is_pair_impl( c ) ) == sizeof( yes_type ) ); Chris@16: BOOST_STATIC_CONSTANT( bool, is_char_ptr_ = sizeof( boost::range_detail::is_char_ptr_impl( ptr ) ) == sizeof( yes_type ) ); Chris@16: BOOST_STATIC_CONSTANT( bool, is_const_char_ptr_ = sizeof( boost::range_detail::is_const_char_ptr_impl( ptr ) ) == sizeof( yes_type ) ); Chris@16: BOOST_STATIC_CONSTANT( bool, is_wchar_t_ptr_ = sizeof( boost::range_detail::is_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) ); Chris@16: BOOST_STATIC_CONSTANT( bool, is_const_wchar_t_ptr_ = sizeof( boost::range_detail::is_const_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) ); Chris@16: BOOST_STATIC_CONSTANT( bool, is_char_array_ = sizeof( boost::range_detail::is_char_array_impl( ptr ) ) == sizeof( yes_type ) ); Chris@16: BOOST_STATIC_CONSTANT( bool, is_wchar_t_array_ = sizeof( boost::range_detail::is_wchar_t_array_impl( ptr ) ) == sizeof( yes_type ) ); Chris@16: BOOST_STATIC_CONSTANT( bool, is_string_ = (boost::type_traits::ice_or::value )); Chris@16: BOOST_STATIC_CONSTANT( bool, is_array_ = boost::is_array::value ); Chris@16: Chris@16: }; Chris@16: Chris@16: template< typename C > Chris@16: class range Chris@16: { Chris@16: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_pair_, Chris@16: boost::range_detail::std_pair_, Chris@16: void >::type pair_t; Chris@16: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_array_, Chris@16: boost::range_detail::array_, Chris@16: pair_t >::type array_t; Chris@16: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_string_, Chris@16: boost::range_detail::string_, Chris@16: array_t >::type string_t; Chris@16: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_const_char_ptr_, Chris@16: boost::range_detail::const_char_ptr_, Chris@16: string_t >::type const_char_ptr_t; Chris@16: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_char_ptr_, Chris@16: boost::range_detail::char_ptr_, Chris@16: const_char_ptr_t >::type char_ptr_t; Chris@16: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_const_wchar_t_ptr_, Chris@16: boost::range_detail::const_wchar_t_ptr_, Chris@16: char_ptr_t >::type const_wchar_ptr_t; Chris@16: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_wchar_t_ptr_, Chris@16: boost::range_detail::wchar_t_ptr_, Chris@16: const_wchar_ptr_t >::type wchar_ptr_t; Chris@16: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_wchar_t_array_, Chris@16: boost::range_detail::wchar_t_array_, Chris@16: wchar_ptr_t >::type wchar_array_t; Chris@16: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_char_array_, Chris@16: boost::range_detail::char_array_, Chris@16: wchar_array_t >::type char_array_t; Chris@16: public: Chris@16: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::is_void::value, Chris@16: boost::range_detail::std_container_, Chris@16: char_array_t >::type type; Chris@16: }; // class 'range' Chris@16: } Chris@16: } Chris@16: Chris@16: #endif Chris@16: