sl@0: // (C) Copyright John Maddock 2005. sl@0: // Use, modification and distribution are subject to the sl@0: // Boost Software License, Version 1.0. (See accompanying file sl@0: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) sl@0: sl@0: #ifndef BOOST_TR1_UTILITY_HPP_INCLUDED sl@0: # define BOOST_TR1_UTILITY_HPP_INCLUDED sl@0: # include sl@0: sl@0: #ifdef BOOST_HAS_TR1_UTILITY sl@0: sl@0: # ifdef BOOST_HAS_INCLUDE_NEXT sl@0: # include_next BOOST_TR1_HEADER(utility) sl@0: # else sl@0: # include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(utility)) sl@0: # endif sl@0: sl@0: #else sl@0: sl@0: #if defined(BOOST_TR1_USE_OLD_TUPLE) sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: sl@0: namespace std{ namespace tr1{ sl@0: sl@0: template struct tuple_size; // forward declaration sl@0: template < int I, class T> struct tuple_element; // forward declaration sl@0: sl@0: #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION sl@0: template sl@0: struct tuple_size< ::std::pair > sl@0: : public ::boost::integral_constant< ::std::size_t, 2> sl@0: { sl@0: }; sl@0: sl@0: template sl@0: struct tuple_element<0, ::std::pair > sl@0: { sl@0: typedef typename std::pair::first_type type; sl@0: }; sl@0: sl@0: template sl@0: struct tuple_element<1, std::pair > sl@0: { sl@0: typedef typename std::pair::second_type type; sl@0: }; sl@0: #endif sl@0: sl@0: namespace tuple_detail{ sl@0: template sl@0: struct tuple_get_result sl@0: { sl@0: typedef typename boost::mpl::if_c::type t1; sl@0: typedef typename boost::add_reference::type type; sl@0: }; sl@0: template sl@0: struct const_tuple_get_result sl@0: { sl@0: typedef typename boost::mpl::if_c::type t1; sl@0: # if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x582)) sl@0: // I have absolutely no idea why add_const is not working here for Borland! sl@0: // It passes all other free-standing tests, some strange interaction going on sl@0: typedef typename boost::add_reference< const t1 >::type type; sl@0: # else sl@0: typedef typename boost::add_const::type t2; sl@0: typedef typename boost::add_reference::type type; sl@0: # endif sl@0: }; sl@0: sl@0: template sl@0: inline typename tuple_detail::tuple_get_result::type get(std::pair& p, const ::boost::true_type&) sl@0: { sl@0: return p.first; sl@0: } sl@0: sl@0: template sl@0: inline typename tuple_detail::const_tuple_get_result::type get(const std::pair& p, const ::boost::true_type&) sl@0: { sl@0: return p.first; sl@0: } sl@0: sl@0: template sl@0: inline typename tuple_detail::tuple_get_result::type get(std::pair& p, const ::boost::false_type&) sl@0: { sl@0: return p.second; sl@0: } sl@0: sl@0: template sl@0: inline typename tuple_detail::const_tuple_get_result::type get(const std::pair& p, const ::boost::false_type&) sl@0: { sl@0: return p.second; sl@0: } sl@0: sl@0: } sl@0: sl@0: template sl@0: inline typename tuple_detail::tuple_get_result::type get(std::pair& p) sl@0: { sl@0: return tuple_detail::get(p, boost::integral_constant()); sl@0: } sl@0: sl@0: template sl@0: inline typename tuple_detail::const_tuple_get_result::type get(const std::pair& p) sl@0: { sl@0: return tuple_detail::get(p, boost::integral_constant()); sl@0: } sl@0: sl@0: } } // namespaces sl@0: sl@0: #else sl@0: sl@0: #include sl@0: sl@0: #endif sl@0: sl@0: #endif sl@0: sl@0: #endif