Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | // tuple.hpp - Boost Tuple Library -------------------------------------- |
| 2 | |
| 3 | // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) |
| 4 | // |
| 5 | // Distributed under the Boost Software License, Version 1.0. (See |
| 6 | // accompanying file LICENSE_1_0.txt or copy at |
| 7 | // http://www.boost.org/LICENSE_1_0.txt) |
| 8 | |
| 9 | // For more information, see http://www.boost.org |
| 10 | |
| 11 | // ----------------------------------------------------------------- |
| 12 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 13 | #ifndef NDNBOOST_TUPLE_HPP |
| 14 | #define NDNBOOST_TUPLE_HPP |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 15 | |
| 16 | #if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730 |
| 17 | // Work around a compiler bug. |
| 18 | // ndnboost::python::tuple has to be seen by the compiler before the |
| 19 | // ndnboost::tuple class template. |
| 20 | namespace ndnboost { namespace python { class tuple; }} |
| 21 | #endif |
| 22 | |
| 23 | #include "ndnboost/config.hpp" |
| 24 | #include "ndnboost/static_assert.hpp" |
| 25 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 26 | #if defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 27 | // The MSVC version |
| 28 | #include "ndnboost/tuple/detail/tuple_basic_no_partial_spec.hpp" |
| 29 | |
| 30 | #else |
| 31 | // other compilers |
| 32 | #include "ndnboost/ref.hpp" |
| 33 | #include "ndnboost/tuple/detail/tuple_basic.hpp" |
| 34 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 35 | #endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 36 | |
| 37 | namespace ndnboost { |
| 38 | |
| 39 | using tuples::tuple; |
| 40 | using tuples::make_tuple; |
| 41 | using tuples::tie; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 42 | #if !defined(NDNBOOST_NO_USING_TEMPLATE) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 43 | using tuples::get; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 44 | #elif !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 45 | // |
| 46 | // The "using tuples::get" statement causes the |
| 47 | // Borland compiler to ICE, use forwarding |
| 48 | // functions instead: |
| 49 | // |
| 50 | template<int N, class HT, class TT> |
| 51 | inline typename tuples::access_traits< |
| 52 | typename tuples::element<N, tuples::cons<HT, TT> >::type |
| 53 | >::non_const_type |
| 54 | get(tuples::cons<HT, TT>& c) { |
| 55 | return tuples::get<N,HT,TT>(c); |
| 56 | } |
| 57 | // get function for const cons-lists, returns a const reference to |
| 58 | // the element. If the element is a reference, returns the reference |
| 59 | // as such (that is, can return a non-const reference) |
| 60 | template<int N, class HT, class TT> |
| 61 | inline typename tuples::access_traits< |
| 62 | typename tuples::element<N, tuples::cons<HT, TT> >::type |
| 63 | >::const_type |
| 64 | get(const tuples::cons<HT, TT>& c) { |
| 65 | return tuples::get<N,HT,TT>(c); |
| 66 | } |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 67 | #else // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 68 | // |
| 69 | // MSVC, using declarations don't mix with templates well, |
| 70 | // so use forwarding functions instead: |
| 71 | // |
| 72 | template<int N, typename Head, typename Tail> |
| 73 | typename tuples::detail::element_ref<N, tuples::cons<Head, Tail> >::RET |
| 74 | get(tuples::cons<Head, Tail>& t, tuples::detail::workaround_holder<N>* = 0) |
| 75 | { |
| 76 | return tuples::detail::get_class<N>::get(t); |
| 77 | } |
| 78 | |
| 79 | template<int N, typename Head, typename Tail> |
| 80 | typename tuples::detail::element_const_ref<N, tuples::cons<Head, Tail> >::RET |
| 81 | get(const tuples::cons<Head, Tail>& t, tuples::detail::workaround_holder<N>* = 0) |
| 82 | { |
| 83 | return tuples::detail::get_class<N>::get(t); |
| 84 | } |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 85 | #endif // NDNBOOST_NO_USING_TEMPLATE |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 86 | |
| 87 | } // end namespace ndnboost |
| 88 | |
| 89 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 90 | #endif // NDNBOOST_TUPLE_HPP |