annotate DEPENDENCIES/generic/include/boost/tr1/utility.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
rev   line source
Chris@16 1 // (C) Copyright John Maddock 2005.
Chris@16 2 // Use, modification and distribution are subject to the
Chris@16 3 // Boost Software License, Version 1.0. (See accompanying file
Chris@16 4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 5
Chris@16 6 #ifndef BOOST_TR1_UTILITY_HPP_INCLUDED
Chris@16 7 # define BOOST_TR1_UTILITY_HPP_INCLUDED
Chris@16 8 # include <boost/tr1/detail/config.hpp>
Chris@16 9
Chris@16 10 #ifdef BOOST_HAS_TR1_UTILITY
Chris@16 11
Chris@16 12 # if defined(BOOST_HAS_INCLUDE_NEXT) && !defined(BOOST_TR1_DISABLE_INCLUDE_NEXT)
Chris@16 13 # include_next BOOST_TR1_HEADER(utility)
Chris@16 14 # else
Chris@16 15 # include <boost/tr1/detail/config_all.hpp>
Chris@16 16 # include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(utility))
Chris@16 17 # endif
Chris@16 18
Chris@16 19 #else
Chris@16 20
Chris@16 21 #if defined(BOOST_TR1_USE_OLD_TUPLE)
Chris@16 22
Chris@16 23 #include <boost/type_traits/integral_constant.hpp>
Chris@16 24 #include <boost/type_traits/add_const.hpp>
Chris@16 25 #include <boost/type_traits/add_reference.hpp>
Chris@16 26 #include <boost/mpl/if.hpp>
Chris@16 27
Chris@16 28
Chris@16 29 namespace std{ namespace tr1{
Chris@16 30
Chris@16 31 template <class T> struct tuple_size; // forward declaration
Chris@16 32 template < int I, class T> struct tuple_element; // forward declaration
Chris@16 33
Chris@16 34 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Chris@16 35 template <class T1, class T2>
Chris@16 36 struct tuple_size< ::std::pair<T1, T2> >
Chris@16 37 : public ::boost::integral_constant< ::std::size_t, 2>
Chris@16 38 {
Chris@16 39 };
Chris@16 40
Chris@16 41 template <class T1, class T2>
Chris@16 42 struct tuple_element<0, ::std::pair<T1, T2> >
Chris@16 43 {
Chris@16 44 typedef typename std::pair<T1, T2>::first_type type;
Chris@16 45 };
Chris@16 46
Chris@16 47 template <class T1, class T2>
Chris@16 48 struct tuple_element<1, std::pair<T1, T2> >
Chris@16 49 {
Chris@16 50 typedef typename std::pair<T1, T2>::second_type type;
Chris@16 51 };
Chris@16 52 #endif
Chris@16 53
Chris@16 54 namespace tuple_detail{
Chris@16 55 template <int I, class T1, class T2>
Chris@16 56 struct tuple_get_result
Chris@16 57 {
Chris@16 58 typedef typename boost::mpl::if_c<I==0, T1, T2>::type t1;
Chris@16 59 typedef typename boost::add_reference<t1>::type type;
Chris@16 60 };
Chris@16 61 template <int I, class T1, class T2>
Chris@16 62 struct const_tuple_get_result
Chris@16 63 {
Chris@16 64 typedef typename boost::mpl::if_c<I==0, T1, T2>::type t1;
Chris@16 65 # if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x582))
Chris@16 66 // I have absolutely no idea why add_const is not working here for Borland!
Chris@16 67 // It passes all other free-standing tests, some strange interaction going on
Chris@16 68 typedef typename boost::add_reference< const t1 >::type type;
Chris@16 69 # else
Chris@16 70 typedef typename boost::add_const<t1>::type t2;
Chris@16 71 typedef typename boost::add_reference<t2>::type type;
Chris@16 72 # endif
Chris@16 73 };
Chris@16 74
Chris@16 75 template<int I, class T1, class T2>
Chris@16 76 inline typename tuple_detail::tuple_get_result<I,T1,T2>::type get(std::pair<T1, T2>& p, const ::boost::true_type&)
Chris@16 77 {
Chris@16 78 return p.first;
Chris@16 79 }
Chris@16 80
Chris@16 81 template<int I, class T1, class T2>
Chris@16 82 inline typename tuple_detail::const_tuple_get_result<I,T1,T2>::type get(const std::pair<T1, T2>& p, const ::boost::true_type&)
Chris@16 83 {
Chris@16 84 return p.first;
Chris@16 85 }
Chris@16 86
Chris@16 87 template<int I, class T1, class T2>
Chris@16 88 inline typename tuple_detail::tuple_get_result<I,T1,T2>::type get(std::pair<T1, T2>& p, const ::boost::false_type&)
Chris@16 89 {
Chris@16 90 return p.second;
Chris@16 91 }
Chris@16 92
Chris@16 93 template<int I, class T1, class T2>
Chris@16 94 inline typename tuple_detail::const_tuple_get_result<I,T1,T2>::type get(const std::pair<T1, T2>& p, const ::boost::false_type&)
Chris@16 95 {
Chris@16 96 return p.second;
Chris@16 97 }
Chris@16 98
Chris@16 99 }
Chris@16 100
Chris@16 101 template<int I, class T1, class T2>
Chris@16 102 inline typename tuple_detail::tuple_get_result<I,T1,T2>::type get(std::pair<T1, T2>& p)
Chris@16 103 {
Chris@16 104 return tuple_detail::get<I>(p, boost::integral_constant<bool, I==0>());
Chris@16 105 }
Chris@16 106
Chris@16 107 template<int I, class T1, class T2>
Chris@16 108 inline typename tuple_detail::const_tuple_get_result<I,T1,T2>::type get(const std::pair<T1, T2>& p)
Chris@16 109 {
Chris@16 110 return tuple_detail::get<I>(p, boost::integral_constant<bool, I==0>());
Chris@16 111 }
Chris@16 112
Chris@16 113 } } // namespaces
Chris@16 114
Chris@16 115 #else
Chris@16 116
Chris@16 117 #include <boost/tr1/tuple.hpp>
Chris@16 118
Chris@16 119 #endif
Chris@16 120
Chris@16 121 #endif
Chris@16 122
Chris@16 123 #endif