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