blob: 40b5804c67be68c2369918acdc5e6e7cef342ddc [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001// 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 Thompson3d613fd2013-10-15 15:39:04 -070013#ifndef NDNBOOST_TUPLE_HPP
14#define NDNBOOST_TUPLE_HPP
Jeff Thompsona28eed82013-08-22 16:21:10 -070015
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.
20namespace ndnboost { namespace python { class tuple; }}
21#endif
22
23#include "ndnboost/config.hpp"
24#include "ndnboost/static_assert.hpp"
25
Jeff Thompson3d613fd2013-10-15 15:39:04 -070026#if defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
Jeff Thompsona28eed82013-08-22 16:21:10 -070027// 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 Thompson3d613fd2013-10-15 15:39:04 -070035#endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Jeff Thompsona28eed82013-08-22 16:21:10 -070036
37namespace ndnboost {
38
39using tuples::tuple;
40using tuples::make_tuple;
41using tuples::tie;
Jeff Thompson3d613fd2013-10-15 15:39:04 -070042#if !defined(NDNBOOST_NO_USING_TEMPLATE)
Jeff Thompsona28eed82013-08-22 16:21:10 -070043using tuples::get;
Jeff Thompson3d613fd2013-10-15 15:39:04 -070044#elif !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
Jeff Thompsona28eed82013-08-22 16:21:10 -070045//
46// The "using tuples::get" statement causes the
47// Borland compiler to ICE, use forwarding
48// functions instead:
49//
50template<int N, class HT, class TT>
51inline typename tuples::access_traits<
52 typename tuples::element<N, tuples::cons<HT, TT> >::type
53 >::non_const_type
54get(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)
60template<int N, class HT, class TT>
61inline typename tuples::access_traits<
62 typename tuples::element<N, tuples::cons<HT, TT> >::type
63 >::const_type
64get(const tuples::cons<HT, TT>& c) {
65 return tuples::get<N,HT,TT>(c);
66}
Jeff Thompson3d613fd2013-10-15 15:39:04 -070067#else // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Jeff Thompsona28eed82013-08-22 16:21:10 -070068//
69// MSVC, using declarations don't mix with templates well,
70// so use forwarding functions instead:
71//
72template<int N, typename Head, typename Tail>
73typename tuples::detail::element_ref<N, tuples::cons<Head, Tail> >::RET
74get(tuples::cons<Head, Tail>& t, tuples::detail::workaround_holder<N>* = 0)
75{
76 return tuples::detail::get_class<N>::get(t);
77}
78
79template<int N, typename Head, typename Tail>
80typename tuples::detail::element_const_ref<N, tuples::cons<Head, Tail> >::RET
81get(const tuples::cons<Head, Tail>& t, tuples::detail::workaround_holder<N>* = 0)
82{
83 return tuples::detail::get_class<N>::get(t);
84}
Jeff Thompson3d613fd2013-10-15 15:39:04 -070085#endif // NDNBOOST_NO_USING_TEMPLATE
Jeff Thompsona28eed82013-08-22 16:21:10 -070086
87} // end namespace ndnboost
88
89
Jeff Thompson3d613fd2013-10-15 15:39:04 -070090#endif // NDNBOOST_TUPLE_HPP