1 // tuple_basic.hpp -----------------------------------------------------
3 // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
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)
9 // For more information, see http://www.boost.org
12 // This and that, Gary Powell.
13 // Fixed return types for get_head/get_tail
14 // ( and other bugs ) per suggestion of Jens Maurer
15 // simplified element type accessors + bug fix (Jeremy Siek)
16 // Several changes/additions according to suggestions by Douglas Gregor,
17 // William Kempf, Vesa Karvonen, John Max Skaller, Ed Brey, Beman Dawes,
21 // 2002 05 01 Hugo Duncan: Fix for Borland after Jaakko's previous changes
22 // 2002 04 18 Jaakko: tuple element types can be void or plain function
23 // types, as long as no object is created.
24 // Tuple objects can no hold even noncopyable types
26 // 2001 10 22 John Maddock
27 // Fixes for Borland C++
28 // 2001 08 30 David Abrahams
29 // Added default constructor for cons<>.
30 // -----------------------------------------------------------------
32 #ifndef BOOST_TUPLE_BASIC_HPP
33 #define BOOST_TUPLE_BASIC_HPP
36 #include <utility> // needed for the assignment from pair to tuple
38 #include "boost/type_traits/cv_traits.hpp"
39 #include "boost/type_traits/function_traits.hpp"
41 #include "boost/detail/workaround.hpp" // needed for BOOST_WORKAROUND
46 // -- null_type --------------------------------------------------------
49 // a helper function to provide a const null_type type temporary
51 inline const null_type
cnull() { return null_type(); }
54 // -- if construct ------------------------------------------------
55 // Proposed by Krzysztof Czarnecki and Ulrich Eisenecker
57 template <bool If
, class Then
, class Else
> struct IF
{ typedef Then RET
; };
59 template <class Then
, class Else
> struct IF
<false, Then
, Else
> {
65 // - cons forward declaration -----------------------------------------------
66 template <class HT
, class TT
> struct cons
;
69 // - tuple forward declaration -----------------------------------------------
71 class T0
= null_type
, class T1
= null_type
, class T2
= null_type
,
72 class T3
= null_type
, class T4
= null_type
, class T5
= null_type
,
73 class T6
= null_type
, class T7
= null_type
, class T8
= null_type
,
77 // tuple_length forward declaration
78 template<class T
> struct length
;
84 // -- generate error template, referencing to non-existing members of this
85 // template is used to produce compilation errors intentionally
89 // - cons getters --------------------------------------------------------
90 // called: get_class<N>::get<RETURN_TYPE>(aTuple)
94 template<class RET
, class HT
, class TT
>
95 inline static RET
get(const cons
<HT
, TT
>& t
)
97 #if BOOST_WORKAROUND(__IBMCPP__,==600)
98 // vacpp 6.0 is not very consistent regarding the member template keyword
99 // Here it generates an error when the template keyword is used.
100 return get_class
<N
-1>::get
<RET
>(t
.tail
);
102 return get_class
<N
-1>::BOOST_NESTED_TEMPLATE get
<RET
>(t
.tail
);
105 template<class RET
, class HT
, class TT
>
106 inline static RET
get(cons
<HT
, TT
>& t
)
108 #if BOOST_WORKAROUND(__IBMCPP__,==600)
109 return get_class
<N
-1>::get
<RET
>(t
.tail
);
111 return get_class
<N
-1>::BOOST_NESTED_TEMPLATE get
<RET
>(t
.tail
);
117 struct get_class
<0> {
118 template<class RET
, class HT
, class TT
>
119 inline static RET
get(const cons
<HT
, TT
>& t
)
123 template<class RET
, class HT
, class TT
>
124 inline static RET
get(cons
<HT
, TT
>& t
)
130 } // end of namespace detail
133 // -cons type accessors ----------------------------------------
134 // typename tuples::element<N,T>::type gets the type of the
135 // Nth element ot T, first element is at index 0
136 // -------------------------------------------------------
138 #ifndef BOOST_NO_CV_SPECIALIZATIONS
140 template<int N
, class T
>
144 typedef typename
T::tail_type Next
;
146 typedef typename element
<N
-1, Next
>::type type
;
151 typedef typename
T::head_type type
;
154 template<int N
, class T
>
155 struct element
<N
, const T
>
158 typedef typename
T::tail_type Next
;
159 typedef typename element
<N
-1, Next
>::type unqualified_type
;
161 #if BOOST_WORKAROUND(__BORLANDC__,<0x600)
162 typedef const unqualified_type type
;
164 typedef typename
boost::add_const
<unqualified_type
>::type type
;
169 struct element
<0,const T
>
171 #if BOOST_WORKAROUND(__BORLANDC__,<0x600)
172 typedef const typename
T::head_type type
;
174 typedef typename
boost::add_const
<typename
T::head_type
>::type type
;
178 #else // def BOOST_NO_CV_SPECIALIZATIONS
182 template<int N
, class T
, bool IsConst
>
186 typedef typename
T::tail_type Next
;
188 typedef typename element_impl
<N
-1, Next
, IsConst
>::type type
;
191 template<int N
, class T
>
192 struct element_impl
<N
, T
, true /* IsConst */>
195 typedef typename
T::tail_type Next
;
197 typedef const typename element_impl
<N
-1, Next
, true>::type type
;
201 struct element_impl
<0, T
, false /* IsConst */>
203 typedef typename
T::head_type type
;
207 struct element_impl
<0, T
, true /* IsConst */>
209 typedef const typename
T::head_type type
;
212 } // end of namespace detail
215 template<int N
, class T
>
217 public detail::element_impl
<N
, T
, ::boost::is_const
<T
>::value
>
224 // -get function templates -----------------------------------------------
225 // Usage: get<N>(aTuple)
227 // -- some traits classes for get functions
229 // access traits lifted from detail namespace to be part of the interface,
230 // (Joel de Guzman's suggestion). Rationale: get functions are part of the
231 // interface, so should the way to express their return types be.
233 template <class T
> struct access_traits
{
234 typedef const T
& const_type
;
235 typedef T
& non_const_type
;
237 typedef const typename
boost::remove_cv
<T
>::type
& parameter_type
;
239 // used as the tuple constructors parameter types
240 // Rationale: non-reference tuple element types can be cv-qualified.
241 // It should be possible to initialize such types with temporaries,
242 // and when binding temporaries to references, the reference must
243 // be non-volatile and const. 8.5.3. (5)
246 template <class T
> struct access_traits
<T
&> {
248 typedef T
& const_type
;
249 typedef T
& non_const_type
;
251 typedef T
& parameter_type
;
254 // get function for non-const cons-lists, returns a reference to the element
256 template<int N
, class HT
, class TT
>
257 inline typename access_traits
<
258 typename element
<N
, cons
<HT
, TT
> >::type
260 get(cons
<HT
, TT
>& c
BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int, N
)) {
261 #if BOOST_WORKAROUND(__IBMCPP__,==600 )
262 return detail::get_class
<N
>::
264 return detail::get_class
<N
>::BOOST_NESTED_TEMPLATE
267 typename access_traits
<
268 typename element
<N
, cons
<HT
, TT
> >::type
274 // get function for const cons-lists, returns a const reference to
275 // the element. If the element is a reference, returns the reference
276 // as such (that is, can return a non-const reference)
277 template<int N
, class HT
, class TT
>
278 inline typename access_traits
<
279 typename element
<N
, cons
<HT
, TT
> >::type
281 get(const cons
<HT
, TT
>& c
BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int, N
)) {
282 #if BOOST_WORKAROUND(__IBMCPP__,==600)
283 return detail::get_class
<N
>::
285 return detail::get_class
<N
>::BOOST_NESTED_TEMPLATE
288 typename access_traits
<
289 typename element
<N
, cons
<HT
, TT
> >::type
295 // -- the cons template --------------------------------------------------
298 // These helper templates wrap void types and plain function types.
299 // The reationale is to allow one to write tuple types with those types
300 // as elements, even though it is not possible to instantiate such object.
301 // E.g: typedef tuple<void> some_type; // ok
302 // but: some_type x; // fails
304 template <class T
> class non_storeable_type
{
305 non_storeable_type();
308 template <class T
> struct wrap_non_storeable_type
{
310 ::boost::is_function
<T
>::value
, non_storeable_type
<T
>, T
313 template <> struct wrap_non_storeable_type
<void> {
314 typedef non_storeable_type
<void> type
;
319 template <class HT
, class TT
>
322 typedef HT head_type
;
323 typedef TT tail_type
;
326 detail::wrap_non_storeable_type
<head_type
>::type stored_head_type
;
328 stored_head_type head
;
331 typename access_traits
<stored_head_type
>::non_const_type
332 get_head() { return head
; }
334 typename access_traits
<tail_type
>::non_const_type
335 get_tail() { return tail
; }
337 typename access_traits
<stored_head_type
>::const_type
338 get_head() const { return head
; }
340 typename access_traits
<tail_type
>::const_type
341 get_tail() const { return tail
; }
343 cons() : head(), tail() {}
344 // cons() : head(detail::default_arg<HT>::f()), tail() {}
346 // the argument for head is not strictly needed, but it prevents
347 // array type elements. This is good, since array type elements
348 // cannot be supported properly in any case (no assignment,
349 // copy works only if the tails are exactly the same type, ...)
351 cons(typename access_traits
<stored_head_type
>::parameter_type h
,
353 : head (h
), tail(t
) {}
355 template <class T1
, class T2
, class T3
, class T4
, class T5
,
356 class T6
, class T7
, class T8
, class T9
, class T10
>
357 cons( T1
& t1
, T2
& t2
, T3
& t3
, T4
& t4
, T5
& t5
,
358 T6
& t6
, T7
& t7
, T8
& t8
, T9
& t9
, T10
& t10
)
360 tail (t2
, t3
, t4
, t5
, t6
, t7
, t8
, t9
, t10
, detail::cnull())
363 template <class T2
, class T3
, class T4
, class T5
,
364 class T6
, class T7
, class T8
, class T9
, class T10
>
365 cons( const null_type
& /*t1*/, T2
& t2
, T3
& t3
, T4
& t4
, T5
& t5
,
366 T6
& t6
, T7
& t7
, T8
& t8
, T9
& t9
, T10
& t10
)
368 tail (t2
, t3
, t4
, t5
, t6
, t7
, t8
, t9
, t10
, detail::cnull())
372 template <class HT2
, class TT2
>
373 cons( const cons
<HT2
, TT2
>& u
) : head(u
.head
), tail(u
.tail
) {}
375 template <class HT2
, class TT2
>
376 cons
& operator=( const cons
<HT2
, TT2
>& u
) {
377 head
=u
.head
; tail
=u
.tail
; return *this;
380 // must define assignment operator explicitly, implicit version is
381 // illformed if HT is a reference (12.8. (12))
382 cons
& operator=(const cons
& u
) {
383 head
= u
.head
; tail
= u
.tail
; return *this;
386 template <class T1
, class T2
>
387 cons
& operator=( const std::pair
<T1
, T2
>& u
) {
388 BOOST_STATIC_ASSERT(length
<cons
>::value
== 2); // check length = 2
389 head
= u
.first
; tail
.head
= u
.second
; return *this;
392 // get member functions (non-const and const)
394 typename access_traits
<
395 typename element
<N
, cons
<HT
, TT
> >::type
398 return boost::tuples::get
<N
>(*this); // delegate to non-member get
402 typename access_traits
<
403 typename element
<N
, cons
<HT
, TT
> >::type
406 return boost::tuples::get
<N
>(*this); // delegate to non-member get
411 struct cons
<HT
, null_type
> {
413 typedef HT head_type
;
414 typedef null_type tail_type
;
415 typedef cons
<HT
, null_type
> self_type
;
418 detail::wrap_non_storeable_type
<head_type
>::type stored_head_type
;
419 stored_head_type head
;
421 typename access_traits
<stored_head_type
>::non_const_type
422 get_head() { return head
; }
424 null_type
get_tail() { return null_type(); }
426 typename access_traits
<stored_head_type
>::const_type
427 get_head() const { return head
; }
429 const null_type
get_tail() const { return null_type(); }
431 // cons() : head(detail::default_arg<HT>::f()) {}
434 cons(typename access_traits
<stored_head_type
>::parameter_type h
,
435 const null_type
& = null_type())
439 cons(T1
& t1
, const null_type
&, const null_type
&, const null_type
&,
440 const null_type
&, const null_type
&, const null_type
&,
441 const null_type
&, const null_type
&, const null_type
&)
444 cons(const null_type
&,
445 const null_type
&, const null_type
&, const null_type
&,
446 const null_type
&, const null_type
&, const null_type
&,
447 const null_type
&, const null_type
&, const null_type
&)
451 cons( const cons
<HT2
, null_type
>& u
) : head(u
.head
) {}
454 cons
& operator=(const cons
<HT2
, null_type
>& u
)
455 { head
= u
.head
; return *this; }
457 // must define assignment operator explicitely, implicit version
458 // is illformed if HT is a reference
459 cons
& operator=(const cons
& u
) { head
= u
.head
; return *this; }
462 typename access_traits
<
463 typename element
<N
, self_type
>::type
465 get(BOOST_EXPLICIT_TEMPLATE_NON_TYPE(int, N
)) {
466 return boost::tuples::get
<N
>(*this);
470 typename access_traits
<
471 typename element
<N
, self_type
>::type
473 get(BOOST_EXPLICIT_TEMPLATE_NON_TYPE(int, N
)) const {
474 return boost::tuples::get
<N
>(*this);
479 // templates for finding out the length of the tuple -------------------
483 BOOST_STATIC_CONSTANT(int, value
= 1 + length
<typename
T::tail_type
>::value
);
487 struct length
<tuple
<> > {
488 BOOST_STATIC_CONSTANT(int, value
= 0);
492 struct length
<tuple
<> const> {
493 BOOST_STATIC_CONSTANT(int, value
= 0);
497 struct length
<null_type
> {
498 BOOST_STATIC_CONSTANT(int, value
= 0);
502 struct length
<null_type
const> {
503 BOOST_STATIC_CONSTANT(int, value
= 0);
508 // Tuple to cons mapper --------------------------------------------------
509 template <class T0
, class T1
, class T2
, class T3
, class T4
,
510 class T5
, class T6
, class T7
, class T8
, class T9
>
511 struct map_tuple_to_cons
514 typename map_tuple_to_cons
<T1
, T2
, T3
, T4
, T5
,
515 T6
, T7
, T8
, T9
, null_type
>::type
519 // The empty tuple is a null_type
521 struct map_tuple_to_cons
<null_type
, null_type
, null_type
, null_type
, null_type
, null_type
, null_type
, null_type
, null_type
, null_type
>
523 typedef null_type type
;
528 // -------------------------------------------------------------------
529 // -- tuple ------------------------------------------------------
530 template <class T0
, class T1
, class T2
, class T3
, class T4
,
531 class T5
, class T6
, class T7
, class T8
, class T9
>
534 public detail::map_tuple_to_cons
<T0
, T1
, T2
, T3
, T4
, T5
, T6
, T7
, T8
, T9
>::type
538 detail::map_tuple_to_cons
<T0
, T1
, T2
, T3
, T4
, T5
, T6
, T7
, T8
, T9
>::type inherited
;
539 typedef typename
inherited::head_type head_type
;
540 typedef typename
inherited::tail_type tail_type
;
543 // access_traits<T>::parameter_type takes non-reference types as const T&
546 tuple(typename access_traits
<T0
>::parameter_type t0
)
547 : inherited(t0
, detail::cnull(), detail::cnull(), detail::cnull(),
548 detail::cnull(), detail::cnull(), detail::cnull(),
549 detail::cnull(), detail::cnull(), detail::cnull()) {}
551 tuple(typename access_traits
<T0
>::parameter_type t0
,
552 typename access_traits
<T1
>::parameter_type t1
)
553 : inherited(t0
, t1
, detail::cnull(), detail::cnull(),
554 detail::cnull(), detail::cnull(), detail::cnull(),
555 detail::cnull(), detail::cnull(), detail::cnull()) {}
557 tuple(typename access_traits
<T0
>::parameter_type t0
,
558 typename access_traits
<T1
>::parameter_type t1
,
559 typename access_traits
<T2
>::parameter_type t2
)
560 : inherited(t0
, t1
, t2
, detail::cnull(), detail::cnull(),
561 detail::cnull(), detail::cnull(), detail::cnull(),
562 detail::cnull(), detail::cnull()) {}
564 tuple(typename access_traits
<T0
>::parameter_type t0
,
565 typename access_traits
<T1
>::parameter_type t1
,
566 typename access_traits
<T2
>::parameter_type t2
,
567 typename access_traits
<T3
>::parameter_type t3
)
568 : inherited(t0
, t1
, t2
, t3
, detail::cnull(), detail::cnull(),
569 detail::cnull(), detail::cnull(), detail::cnull(),
572 tuple(typename access_traits
<T0
>::parameter_type t0
,
573 typename access_traits
<T1
>::parameter_type t1
,
574 typename access_traits
<T2
>::parameter_type t2
,
575 typename access_traits
<T3
>::parameter_type t3
,
576 typename access_traits
<T4
>::parameter_type t4
)
577 : inherited(t0
, t1
, t2
, t3
, t4
, detail::cnull(), detail::cnull(),
578 detail::cnull(), detail::cnull(), detail::cnull()) {}
580 tuple(typename access_traits
<T0
>::parameter_type t0
,
581 typename access_traits
<T1
>::parameter_type t1
,
582 typename access_traits
<T2
>::parameter_type t2
,
583 typename access_traits
<T3
>::parameter_type t3
,
584 typename access_traits
<T4
>::parameter_type t4
,
585 typename access_traits
<T5
>::parameter_type t5
)
586 : inherited(t0
, t1
, t2
, t3
, t4
, t5
, detail::cnull(), detail::cnull(),
587 detail::cnull(), detail::cnull()) {}
589 tuple(typename access_traits
<T0
>::parameter_type t0
,
590 typename access_traits
<T1
>::parameter_type t1
,
591 typename access_traits
<T2
>::parameter_type t2
,
592 typename access_traits
<T3
>::parameter_type t3
,
593 typename access_traits
<T4
>::parameter_type t4
,
594 typename access_traits
<T5
>::parameter_type t5
,
595 typename access_traits
<T6
>::parameter_type t6
)
596 : inherited(t0
, t1
, t2
, t3
, t4
, t5
, t6
, detail::cnull(),
597 detail::cnull(), detail::cnull()) {}
599 tuple(typename access_traits
<T0
>::parameter_type t0
,
600 typename access_traits
<T1
>::parameter_type t1
,
601 typename access_traits
<T2
>::parameter_type t2
,
602 typename access_traits
<T3
>::parameter_type t3
,
603 typename access_traits
<T4
>::parameter_type t4
,
604 typename access_traits
<T5
>::parameter_type t5
,
605 typename access_traits
<T6
>::parameter_type t6
,
606 typename access_traits
<T7
>::parameter_type t7
)
607 : inherited(t0
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, detail::cnull(),
610 tuple(typename access_traits
<T0
>::parameter_type t0
,
611 typename access_traits
<T1
>::parameter_type t1
,
612 typename access_traits
<T2
>::parameter_type t2
,
613 typename access_traits
<T3
>::parameter_type t3
,
614 typename access_traits
<T4
>::parameter_type t4
,
615 typename access_traits
<T5
>::parameter_type t5
,
616 typename access_traits
<T6
>::parameter_type t6
,
617 typename access_traits
<T7
>::parameter_type t7
,
618 typename access_traits
<T8
>::parameter_type t8
)
619 : inherited(t0
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
, detail::cnull()) {}
621 tuple(typename access_traits
<T0
>::parameter_type t0
,
622 typename access_traits
<T1
>::parameter_type t1
,
623 typename access_traits
<T2
>::parameter_type t2
,
624 typename access_traits
<T3
>::parameter_type t3
,
625 typename access_traits
<T4
>::parameter_type t4
,
626 typename access_traits
<T5
>::parameter_type t5
,
627 typename access_traits
<T6
>::parameter_type t6
,
628 typename access_traits
<T7
>::parameter_type t7
,
629 typename access_traits
<T8
>::parameter_type t8
,
630 typename access_traits
<T9
>::parameter_type t9
)
631 : inherited(t0
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
, t9
) {}
634 template<class U1
, class U2
>
635 tuple(const cons
<U1
, U2
>& p
) : inherited(p
) {}
637 template <class U1
, class U2
>
638 tuple
& operator=(const cons
<U1
, U2
>& k
) {
639 inherited::operator=(k
);
643 template <class U1
, class U2
>
644 tuple
& operator=(const std::pair
<U1
, U2
>& k
) {
645 BOOST_STATIC_ASSERT(length
<tuple
>::value
== 2);// check_length = 2
646 this->head
= k
.first
;
647 this->tail
.head
= k
.second
;
655 class tuple
<null_type
, null_type
, null_type
, null_type
, null_type
, null_type
, null_type
, null_type
, null_type
, null_type
> :
659 typedef null_type inherited
;
663 // Swallows any assignment (by Doug Gregor)
666 struct swallow_assign
{
669 swallow_assign
const& operator=(const T
&) const {
674 } // namespace detail
676 // "ignore" allows tuple positions to be ignored when using "tie".
677 detail::swallow_assign
const ignore
= detail::swallow_assign();
679 // ---------------------------------------------------------------------------
680 // The call_traits for make_tuple
681 // Honours the reference_wrapper class.
683 // Must be instantiated with plain or const plain types (not with references)
685 // from template<class T> foo(const T& t) : make_tuple_traits<const T>::type
686 // from template<class T> foo(T& t) : make_tuple_traits<T>::type
690 // references -> compile_time_error
691 // reference_wrapper<T> -> T&
692 // const reference_wrapper<T> -> T&
693 // array -> const ref array
697 struct make_tuple_traits
{
700 // commented away, see below (JJ)
701 // typedef typename IF<
702 // boost::is_function<T>::value,
708 // The is_function test was there originally for plain function types,
709 // which can't be stored as such (we must either store them as references or
710 // pointers). Such a type could be formed if make_tuple was called with a
711 // reference to a function.
712 // But this would mean that a const qualified function type was formed in
713 // the make_tuple function and hence make_tuple can't take a function
714 // reference as a parameter, and thus T can't be a function type.
715 // So is_function test was removed.
716 // (14.8.3. says that type deduction fails if a cv-qualified function type
717 // is created. (It only applies for the case of explicitly specifying template
718 // args, though?)) (JJ)
721 struct make_tuple_traits
<T
&> {
723 detail::generate_error
<T
&>::
724 do_not_use_with_reference_type error
;
727 // Arrays can't be stored as plain types; convert them to references.
728 // All arrays are converted to const. This is because make_tuple takes its
729 // parameters as const T& and thus the knowledge of the potential
730 // non-constness of actual argument is lost.
731 template<class T
, int n
> struct make_tuple_traits
<T
[n
]> {
732 typedef const T (&type
)[n
];
735 template<class T
, int n
>
736 struct make_tuple_traits
<const T
[n
]> {
737 typedef const T (&type
)[n
];
740 template<class T
, int n
> struct make_tuple_traits
<volatile T
[n
]> {
741 typedef const volatile T (&type
)[n
];
744 template<class T
, int n
>
745 struct make_tuple_traits
<const volatile T
[n
]> {
746 typedef const volatile T (&type
)[n
];
750 struct make_tuple_traits
<reference_wrapper
<T
> >{
755 struct make_tuple_traits
<const reference_wrapper
<T
> >{
764 // a helper traits to make the make_tuple functions shorter (Vesa Karvonen's
767 class T0
= null_type
, class T1
= null_type
, class T2
= null_type
,
768 class T3
= null_type
, class T4
= null_type
, class T5
= null_type
,
769 class T6
= null_type
, class T7
= null_type
, class T8
= null_type
,
772 struct make_tuple_mapper
{
774 tuple
<typename make_tuple_traits
<T0
>::type
,
775 typename make_tuple_traits
<T1
>::type
,
776 typename make_tuple_traits
<T2
>::type
,
777 typename make_tuple_traits
<T3
>::type
,
778 typename make_tuple_traits
<T4
>::type
,
779 typename make_tuple_traits
<T5
>::type
,
780 typename make_tuple_traits
<T6
>::type
,
781 typename make_tuple_traits
<T7
>::type
,
782 typename make_tuple_traits
<T8
>::type
,
783 typename make_tuple_traits
<T9
>::type
> type
;
788 // -make_tuple function templates -----------------------------------
789 inline tuple
<> make_tuple() {
794 inline typename
detail::make_tuple_mapper
<T0
>::type
795 make_tuple(const T0
& t0
) {
796 typedef typename
detail::make_tuple_mapper
<T0
>::type t
;
800 template<class T0
, class T1
>
801 inline typename
detail::make_tuple_mapper
<T0
, T1
>::type
802 make_tuple(const T0
& t0
, const T1
& t1
) {
803 typedef typename
detail::make_tuple_mapper
<T0
, T1
>::type t
;
807 template<class T0
, class T1
, class T2
>
808 inline typename
detail::make_tuple_mapper
<T0
, T1
, T2
>::type
809 make_tuple(const T0
& t0
, const T1
& t1
, const T2
& t2
) {
810 typedef typename
detail::make_tuple_mapper
<T0
, T1
, T2
>::type t
;
811 return t(t0
, t1
, t2
);
814 template<class T0
, class T1
, class T2
, class T3
>
815 inline typename
detail::make_tuple_mapper
<T0
, T1
, T2
, T3
>::type
816 make_tuple(const T0
& t0
, const T1
& t1
, const T2
& t2
, const T3
& t3
) {
817 typedef typename
detail::make_tuple_mapper
<T0
, T1
, T2
, T3
>::type t
;
818 return t(t0
, t1
, t2
, t3
);
821 template<class T0
, class T1
, class T2
, class T3
, class T4
>
822 inline typename
detail::make_tuple_mapper
<T0
, T1
, T2
, T3
, T4
>::type
823 make_tuple(const T0
& t0
, const T1
& t1
, const T2
& t2
, const T3
& t3
,
825 typedef typename
detail::make_tuple_mapper
<T0
, T1
, T2
, T3
, T4
>::type t
;
826 return t(t0
, t1
, t2
, t3
, t4
);
829 template<class T0
, class T1
, class T2
, class T3
, class T4
, class T5
>
830 inline typename
detail::make_tuple_mapper
<T0
, T1
, T2
, T3
, T4
, T5
>::type
831 make_tuple(const T0
& t0
, const T1
& t1
, const T2
& t2
, const T3
& t3
,
832 const T4
& t4
, const T5
& t5
) {
833 typedef typename
detail::make_tuple_mapper
<T0
, T1
, T2
, T3
, T4
, T5
>::type t
;
834 return t(t0
, t1
, t2
, t3
, t4
, t5
);
837 template<class T0
, class T1
, class T2
, class T3
, class T4
, class T5
, class T6
>
838 inline typename
detail::make_tuple_mapper
<T0
, T1
, T2
, T3
, T4
, T5
, T6
>::type
839 make_tuple(const T0
& t0
, const T1
& t1
, const T2
& t2
, const T3
& t3
,
840 const T4
& t4
, const T5
& t5
, const T6
& t6
) {
841 typedef typename
detail::make_tuple_mapper
842 <T0
, T1
, T2
, T3
, T4
, T5
, T6
>::type t
;
843 return t(t0
, t1
, t2
, t3
, t4
, t5
, t6
);
846 template<class T0
, class T1
, class T2
, class T3
, class T4
, class T5
, class T6
,
848 inline typename
detail::make_tuple_mapper
<T0
, T1
, T2
, T3
, T4
, T5
, T6
, T7
>::type
849 make_tuple(const T0
& t0
, const T1
& t1
, const T2
& t2
, const T3
& t3
,
850 const T4
& t4
, const T5
& t5
, const T6
& t6
, const T7
& t7
) {
851 typedef typename
detail::make_tuple_mapper
852 <T0
, T1
, T2
, T3
, T4
, T5
, T6
, T7
>::type t
;
853 return t(t0
, t1
, t2
, t3
, t4
, t5
, t6
, t7
);
856 template<class T0
, class T1
, class T2
, class T3
, class T4
, class T5
, class T6
,
858 inline typename
detail::make_tuple_mapper
859 <T0
, T1
, T2
, T3
, T4
, T5
, T6
, T7
, T8
>::type
860 make_tuple(const T0
& t0
, const T1
& t1
, const T2
& t2
, const T3
& t3
,
861 const T4
& t4
, const T5
& t5
, const T6
& t6
, const T7
& t7
,
863 typedef typename
detail::make_tuple_mapper
864 <T0
, T1
, T2
, T3
, T4
, T5
, T6
, T7
, T8
>::type t
;
865 return t(t0
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
868 template<class T0
, class T1
, class T2
, class T3
, class T4
, class T5
, class T6
,
869 class T7
, class T8
, class T9
>
870 inline typename
detail::make_tuple_mapper
871 <T0
, T1
, T2
, T3
, T4
, T5
, T6
, T7
, T8
, T9
>::type
872 make_tuple(const T0
& t0
, const T1
& t1
, const T2
& t2
, const T3
& t3
,
873 const T4
& t4
, const T5
& t5
, const T6
& t6
, const T7
& t7
,
874 const T8
& t8
, const T9
& t9
) {
875 typedef typename
detail::make_tuple_mapper
876 <T0
, T1
, T2
, T3
, T4
, T5
, T6
, T7
, T8
, T9
>::type t
;
877 return t(t0
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
, t9
);
882 // Tie function templates -------------------------------------------------
884 inline tuple
<T1
&> tie(T1
& t1
) {
885 return tuple
<T1
&> (t1
);
888 template<class T1
, class T2
>
889 inline tuple
<T1
&, T2
&> tie(T1
& t1
, T2
& t2
) {
890 return tuple
<T1
&, T2
&> (t1
, t2
);
893 template<class T1
, class T2
, class T3
>
894 inline tuple
<T1
&, T2
&, T3
&> tie(T1
& t1
, T2
& t2
, T3
& t3
) {
895 return tuple
<T1
&, T2
&, T3
&> (t1
, t2
, t3
);
898 template<class T1
, class T2
, class T3
, class T4
>
899 inline tuple
<T1
&, T2
&, T3
&, T4
&> tie(T1
& t1
, T2
& t2
, T3
& t3
, T4
& t4
) {
900 return tuple
<T1
&, T2
&, T3
&, T4
&> (t1
, t2
, t3
, t4
);
903 template<class T1
, class T2
, class T3
, class T4
, class T5
>
904 inline tuple
<T1
&, T2
&, T3
&, T4
&, T5
&>
905 tie(T1
& t1
, T2
& t2
, T3
& t3
, T4
& t4
, T5
& t5
) {
906 return tuple
<T1
&, T2
&, T3
&, T4
&, T5
&> (t1
, t2
, t3
, t4
, t5
);
909 template<class T1
, class T2
, class T3
, class T4
, class T5
, class T6
>
910 inline tuple
<T1
&, T2
&, T3
&, T4
&, T5
&, T6
&>
911 tie(T1
& t1
, T2
& t2
, T3
& t3
, T4
& t4
, T5
& t5
, T6
& t6
) {
912 return tuple
<T1
&, T2
&, T3
&, T4
&, T5
&, T6
&> (t1
, t2
, t3
, t4
, t5
, t6
);
915 template<class T1
, class T2
, class T3
, class T4
, class T5
, class T6
, class T7
>
916 inline tuple
<T1
&, T2
&, T3
&, T4
&, T5
&, T6
&, T7
&>
917 tie(T1
& t1
, T2
& t2
, T3
& t3
, T4
& t4
, T5
& t5
, T6
& t6
, T7
& t7
) {
918 return tuple
<T1
&, T2
&, T3
&, T4
&, T5
&, T6
&, T7
&> (t1
, t2
, t3
, t4
, t5
, t6
, t7
);
921 template<class T1
, class T2
, class T3
, class T4
, class T5
, class T6
, class T7
,
923 inline tuple
<T1
&, T2
&, T3
&, T4
&, T5
&, T6
&, T7
&, T8
&>
924 tie(T1
& t1
, T2
& t2
, T3
& t3
, T4
& t4
, T5
& t5
, T6
& t6
, T7
& t7
, T8
& t8
) {
925 return tuple
<T1
&, T2
&, T3
&, T4
&, T5
&, T6
&, T7
&, T8
&>
926 (t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
929 template<class T1
, class T2
, class T3
, class T4
, class T5
, class T6
, class T7
,
931 inline tuple
<T1
&, T2
&, T3
&, T4
&, T5
&, T6
&, T7
&, T8
&, T9
&>
932 tie(T1
& t1
, T2
& t2
, T3
& t3
, T4
& t4
, T5
& t5
, T6
& t6
, T7
& t7
, T8
& t8
,
934 return tuple
<T1
&, T2
&, T3
&, T4
&, T5
&, T6
&, T7
&, T8
&, T9
&>
935 (t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
, t9
);
938 template<class T1
, class T2
, class T3
, class T4
, class T5
, class T6
, class T7
,
939 class T8
, class T9
, class T10
>
940 inline tuple
<T1
&, T2
&, T3
&, T4
&, T5
&, T6
&, T7
&, T8
&, T9
&, T10
&>
941 tie(T1
& t1
, T2
& t2
, T3
& t3
, T4
& t4
, T5
& t5
, T6
& t6
, T7
& t7
, T8
& t8
,
943 return tuple
<T1
&, T2
&, T3
&, T4
&, T5
&, T6
&, T7
&, T8
&, T9
&, T10
&>
944 (t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
, t9
, t10
);
947 } // end of namespace tuples
948 } // end of namespace boost
951 #endif // BOOST_TUPLE_BASIC_HPP