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_COMMON_HPP sl@0: #define BOOST_RANGE_DETAIL_COMMON_HPP sl@0: sl@0: #if defined(_MSC_VER) && (_MSC_VER >= 1200) sl@0: # pragma once sl@0: #endif sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: // missing partial specialization workaround. sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: namespace boost sl@0: { sl@0: namespace range_detail sl@0: { sl@0: // 1 = std containers sl@0: // 2 = std::pair sl@0: // 3 = const std::pair sl@0: // 4 = array sl@0: // 5 = const array sl@0: // 6 = char array sl@0: // 7 = wchar_t array sl@0: // 8 = char* sl@0: // 9 = const char* sl@0: // 10 = whar_t* sl@0: // 11 = const wchar_t* sl@0: // 12 = string sl@0: sl@0: typedef mpl::int_<1>::type std_container_; sl@0: typedef mpl::int_<2>::type std_pair_; sl@0: typedef mpl::int_<3>::type const_std_pair_; sl@0: typedef mpl::int_<4>::type array_; sl@0: typedef mpl::int_<5>::type const_array_; sl@0: typedef mpl::int_<6>::type char_array_; sl@0: typedef mpl::int_<7>::type wchar_t_array_; sl@0: typedef mpl::int_<8>::type char_ptr_; sl@0: typedef mpl::int_<9>::type const_char_ptr_; sl@0: typedef mpl::int_<10>::type wchar_t_ptr_; sl@0: typedef mpl::int_<11>::type const_wchar_t_ptr_; sl@0: typedef mpl::int_<12>::type string_; sl@0: sl@0: template< typename C > sl@0: struct range_helper sl@0: { sl@0: static C* c; sl@0: static C ptr; sl@0: sl@0: BOOST_STATIC_CONSTANT( bool, is_pair_ = sizeof( boost::range_detail::is_pair_impl( c ) ) == sizeof( yes_type ) ); sl@0: BOOST_STATIC_CONSTANT( bool, is_char_ptr_ = sizeof( boost::range_detail::is_char_ptr_impl( ptr ) ) == sizeof( yes_type ) ); sl@0: BOOST_STATIC_CONSTANT( bool, is_const_char_ptr_ = sizeof( boost::range_detail::is_const_char_ptr_impl( ptr ) ) == sizeof( yes_type ) ); sl@0: BOOST_STATIC_CONSTANT( bool, is_wchar_t_ptr_ = sizeof( boost::range_detail::is_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) ); sl@0: 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: BOOST_STATIC_CONSTANT( bool, is_char_array_ = sizeof( boost::range_detail::is_char_array_impl( ptr ) ) == sizeof( yes_type ) ); sl@0: BOOST_STATIC_CONSTANT( bool, is_wchar_t_array_ = sizeof( boost::range_detail::is_wchar_t_array_impl( ptr ) ) == sizeof( yes_type ) ); sl@0: BOOST_STATIC_CONSTANT( bool, is_string_ = (boost::type_traits::ice_or::value )); sl@0: BOOST_STATIC_CONSTANT( bool, is_array_ = boost::is_array::value ); sl@0: sl@0: }; sl@0: sl@0: template< typename C > sl@0: class range sl@0: { sl@0: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_pair_, sl@0: boost::range_detail::std_pair_, sl@0: void >::type pair_t; sl@0: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_array_, sl@0: boost::range_detail::array_, sl@0: pair_t >::type array_t; sl@0: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_string_, sl@0: boost::range_detail::string_, sl@0: array_t >::type string_t; sl@0: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_const_char_ptr_, sl@0: boost::range_detail::const_char_ptr_, sl@0: string_t >::type const_char_ptr_t; sl@0: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_char_ptr_, sl@0: boost::range_detail::char_ptr_, sl@0: const_char_ptr_t >::type char_ptr_t; sl@0: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_const_wchar_t_ptr_, sl@0: boost::range_detail::const_wchar_t_ptr_, sl@0: char_ptr_t >::type const_wchar_ptr_t; sl@0: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_wchar_t_ptr_, sl@0: boost::range_detail::wchar_t_ptr_, sl@0: const_wchar_ptr_t >::type wchar_ptr_t; sl@0: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_wchar_t_array_, sl@0: boost::range_detail::wchar_t_array_, sl@0: wchar_ptr_t >::type wchar_array_t; sl@0: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper::is_char_array_, sl@0: boost::range_detail::char_array_, sl@0: wchar_array_t >::type char_array_t; sl@0: public: sl@0: typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::is_void::value, sl@0: boost::range_detail::std_container_, sl@0: char_array_t >::type type; sl@0: }; // class 'range' sl@0: } sl@0: } sl@0: sl@0: #endif