1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/tr1/utility.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,122 @@
1.4 +// (C) Copyright John Maddock 2005.
1.5 +// Use, modification and distribution are subject to the
1.6 +// Boost Software License, Version 1.0. (See accompanying file
1.7 +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
1.8 +
1.9 +#ifndef BOOST_TR1_UTILITY_HPP_INCLUDED
1.10 +# define BOOST_TR1_UTILITY_HPP_INCLUDED
1.11 +# include <boost/tr1/detail/config.hpp>
1.12 +
1.13 +#ifdef BOOST_HAS_TR1_UTILITY
1.14 +
1.15 +# ifdef BOOST_HAS_INCLUDE_NEXT
1.16 +# include_next BOOST_TR1_HEADER(utility)
1.17 +# else
1.18 +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(utility))
1.19 +# endif
1.20 +
1.21 +#else
1.22 +
1.23 +#if defined(BOOST_TR1_USE_OLD_TUPLE)
1.24 +
1.25 +#include <boost/type_traits/integral_constant.hpp>
1.26 +#include <boost/type_traits/add_const.hpp>
1.27 +#include <boost/type_traits/add_reference.hpp>
1.28 +#include <boost/mpl/if.hpp>
1.29 +
1.30 +
1.31 +namespace std{ namespace tr1{
1.32 +
1.33 +template <class T> struct tuple_size; // forward declaration
1.34 +template < int I, class T> struct tuple_element; // forward declaration
1.35 +
1.36 +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
1.37 +template <class T1, class T2>
1.38 +struct tuple_size< ::std::pair<T1, T2> >
1.39 + : public ::boost::integral_constant< ::std::size_t, 2>
1.40 +{
1.41 +};
1.42 +
1.43 +template <class T1, class T2>
1.44 +struct tuple_element<0, ::std::pair<T1, T2> >
1.45 +{
1.46 + typedef typename std::pair<T1, T2>::first_type type;
1.47 +};
1.48 +
1.49 +template <class T1, class T2>
1.50 +struct tuple_element<1, std::pair<T1, T2> >
1.51 +{
1.52 + typedef typename std::pair<T1, T2>::second_type type;
1.53 +};
1.54 +#endif
1.55 +
1.56 +namespace tuple_detail{
1.57 + template <int I, class T1, class T2>
1.58 + struct tuple_get_result
1.59 + {
1.60 + typedef typename boost::mpl::if_c<I==0, T1, T2>::type t1;
1.61 + typedef typename boost::add_reference<t1>::type type;
1.62 + };
1.63 + template <int I, class T1, class T2>
1.64 + struct const_tuple_get_result
1.65 + {
1.66 + typedef typename boost::mpl::if_c<I==0, T1, T2>::type t1;
1.67 +# if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x582))
1.68 + // I have absolutely no idea why add_const is not working here for Borland!
1.69 + // It passes all other free-standing tests, some strange interaction going on
1.70 + typedef typename boost::add_reference< const t1 >::type type;
1.71 +# else
1.72 + typedef typename boost::add_const<t1>::type t2;
1.73 + typedef typename boost::add_reference<t2>::type type;
1.74 +# endif
1.75 + };
1.76 +
1.77 +template<int I, class T1, class T2>
1.78 +inline typename tuple_detail::tuple_get_result<I,T1,T2>::type get(std::pair<T1, T2>& p, const ::boost::true_type&)
1.79 +{
1.80 + return p.first;
1.81 +}
1.82 +
1.83 +template<int I, class T1, class T2>
1.84 +inline typename tuple_detail::const_tuple_get_result<I,T1,T2>::type get(const std::pair<T1, T2>& p, const ::boost::true_type&)
1.85 +{
1.86 + return p.first;
1.87 +}
1.88 +
1.89 +template<int I, class T1, class T2>
1.90 +inline typename tuple_detail::tuple_get_result<I,T1,T2>::type get(std::pair<T1, T2>& p, const ::boost::false_type&)
1.91 +{
1.92 + return p.second;
1.93 +}
1.94 +
1.95 +template<int I, class T1, class T2>
1.96 +inline typename tuple_detail::const_tuple_get_result<I,T1,T2>::type get(const std::pair<T1, T2>& p, const ::boost::false_type&)
1.97 +{
1.98 + return p.second;
1.99 +}
1.100 +
1.101 +}
1.102 +
1.103 +template<int I, class T1, class T2>
1.104 +inline typename tuple_detail::tuple_get_result<I,T1,T2>::type get(std::pair<T1, T2>& p)
1.105 +{
1.106 + return tuple_detail::get<I>(p, boost::integral_constant<bool, I==0>());
1.107 +}
1.108 +
1.109 +template<int I, class T1, class T2>
1.110 +inline typename tuple_detail::const_tuple_get_result<I,T1,T2>::type get(const std::pair<T1, T2>& p)
1.111 +{
1.112 + return tuple_detail::get<I>(p, boost::integral_constant<bool, I==0>());
1.113 +}
1.114 +
1.115 +} } // namespaces
1.116 +
1.117 +#else
1.118 +
1.119 +#include <boost/tr1/tuple.hpp>
1.120 +
1.121 +#endif
1.122 +
1.123 +#endif
1.124 +
1.125 +#endif