1 // tuple_basic.hpp -----------------------------------------------------
3 // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
5 // Permission to copy, use, sell and distribute this software is granted
6 // provided this copyright notice appears in all copies.
7 // Permission to modify the code and to distribute modified code is granted
8 // provided this copyright notice appears in all copies, and a notice
9 // that the code was modified is included with the copyright notice.
11 // This software is provided "as is" without express or implied warranty,
12 // and with no claim as to its suitability for any purpose.
14 // For more information, see http://www.boost.org
17 // This and that, Gary Powell.
18 // Fixed return types for get_head/get_tail
19 // ( and other bugs ) per suggestion of Jens Maurer
20 // simplified element type accessors + bug fix (Jeremy Siek)
21 // Several changes/additions according to suggestions by Doug Gregor,
22 // William Kempf, Vesa Karvonen, John Max Skaller, Ed Brey, Beman Davis,
26 // 2002 05 01 Hugo Duncan: Fix for Borland after Jaakko's previous changes
27 // 2002 04 18 Jaakko: tuple element types can be void or plain function
28 // types, as long as no object is created.
29 // Tuple objects can no hold even noncopyable types
31 // 2001 10 22 John Maddock
32 // Fixes for Borland C++
33 // 2001 08 30 David Abrahams
34 // Added default constructor for cons<>.
35 // -----------------------------------------------------------------
37 #ifndef BOOST_TUPLE_BASIC_HPP
38 #define BOOST_TUPLE_BASIC_HPP
41 #include <utility> // needed for the assignment from pair to tuple
43 #include "boost/type_traits/cv_traits.hpp"
44 #include "boost/type_traits/function_traits.hpp"
49 // -- null_type --------------------------------------------------------
52 // a helper function to provide a const null_type type temporary
54 inline const null_type cnull() { return null_type(); }
57 // -- if construct ------------------------------------------------
58 // Proposed by Krzysztof Czarnecki and Ulrich Eisenecker
60 template <bool If, class Then, class Else> struct IF { typedef Then RET; };
62 template <class Then, class Else> struct IF<false, Then, Else> {
68 // - cons forward declaration -----------------------------------------------
69 template <class HT, class TT> struct cons;
72 // - tuple forward declaration -----------------------------------------------
74 class T0 = null_type, class T1 = null_type, class T2 = null_type,
75 class T3 = null_type, class T4 = null_type, class T5 = null_type,
76 class T6 = null_type, class T7 = null_type, class T8 = null_type,
80 // tuple_length forward declaration
81 template<class T> struct length;
87 #ifdef BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS
89 template<int N> struct workaround_holder {};
91 # define BOOST_TUPLE_DUMMY_PARM , detail::workaround_holder<N>* = 0
92 # define BOOST_TUPLE_SINGLE_DUMMY_PARM detail::workaround_holder<N>* = 0
94 # define BOOST_TUPLE_DUMMY_PARM
95 # define BOOST_TUPLE_SINGLE_DUMMY_PARM
98 // -- generate error template, referencing to non-existing members of this
99 // template is used to produce compilation errors intentionally
101 class generate_error;
103 // - cons getters --------------------------------------------------------
104 // called: get_class<N>::get<RETURN_TYPE>(aTuple)
108 template<class RET, class HT, class TT >
109 inline static RET get(const cons<HT, TT>& t)
111 return get_class<N-1>::template get<RET>(t.tail);
113 template<class RET, class HT, class TT >
114 inline static RET get(cons<HT, TT>& t)
116 return get_class<N-1>::template get<RET>(t.tail);
121 struct get_class<0> {
122 template<class RET, class HT, class TT>
123 inline static RET get(const cons<HT, TT>& t)
127 template<class RET, class HT, class TT>
128 inline static RET get(cons<HT, TT>& t)
134 } // end of namespace detail
137 // -cons type accessors ----------------------------------------
138 // typename tuples::element<N,T>::type gets the type of the
139 // Nth element ot T, first element is at index 0
140 // -------------------------------------------------------
142 template<int N, class T>
146 typedef typename T::tail_type Next;
148 typedef typename element<N-1, Next>::type type;
153 typedef typename T::head_type type;
156 // -get function templates -----------------------------------------------
157 // Usage: get<N>(aTuple)
159 // -- some traits classes for get functions
161 // access traits lifted from detail namespace to be part of the interface,
162 // (Joel de Guzman's suggestion). Rationale: get functions are part of the
163 // interface, so should the way to express their return types be.
165 template <class T> struct access_traits {
166 typedef const T& const_type;
167 typedef T& non_const_type;
169 typedef const typename boost::remove_cv<T>::type& parameter_type;
171 // used as the tuple constructors parameter types
172 // Rationale: non-reference tuple element types can be cv-qualified.
173 // It should be possible to initialize such types with temporaries,
174 // and when binding temporaries to references, the reference must
175 // be non-volatile and const. 8.5.3. (5)
178 template <class T> struct access_traits<T&> {
180 typedef T& const_type;
181 typedef T& non_const_type;
183 typedef T& parameter_type;
186 // get function for non-const cons-lists, returns a reference to the element
188 template<int N, class HT, class TT>
189 inline typename access_traits<
190 typename element<N, cons<HT, TT> >::type
192 get(cons<HT, TT>& c BOOST_TUPLE_DUMMY_PARM) {
193 return detail::get_class<N>::template
195 typename access_traits<
196 typename element<N, cons<HT, TT> >::type
197 >::non_const_type>(c);
200 // get function for const cons-lists, returns a const reference to
201 // the element. If the element is a reference, returns the reference
202 // as such (that is, can return a non-const reference)
203 template<int N, class HT, class TT>
204 inline typename access_traits<
205 typename element<N, cons<HT, TT> >::type
207 get(const cons<HT, TT>& c BOOST_TUPLE_DUMMY_PARM) {
208 return detail::get_class<N>::template
210 typename access_traits<
211 typename element<N, cons<HT, TT> >::type
215 // -- the cons template --------------------------------------------------
218 // These helper templates wrap void types and plain function types.
219 // The reationale is to allow one to write tuple types with those types
220 // as elements, even though it is not possible to instantiate such object.
221 // E.g: typedef tuple<void> some_type; // ok
222 // but: some_type x; // fails
224 template <class T> class non_storeable_type {
225 non_storeable_type();
228 template <class T> struct wrap_non_storeable_type {
230 ::boost::is_function<T>::value, non_storeable_type<T>, T
233 template <> struct wrap_non_storeable_type<void> {
234 typedef non_storeable_type<void> type;
239 template <class HT, class TT>
242 typedef HT head_type;
243 typedef TT tail_type;
246 detail::wrap_non_storeable_type<head_type>::type stored_head_type;
248 stored_head_type head;
251 typename access_traits<stored_head_type>::non_const_type
252 get_head() { return head; }
254 typename access_traits<tail_type>::non_const_type
255 get_tail() { return tail; }
257 typename access_traits<stored_head_type>::const_type
258 get_head() const { return head; }
260 typename access_traits<tail_type>::const_type
261 get_tail() const { return tail; }
263 cons() : head(), tail() {}
264 // cons() : head(detail::default_arg<HT>::f()), tail() {}
266 // the argument for head is not strictly needed, but it prevents
267 // array type elements. This is good, since array type elements
268 // cannot be supported properly in any case (no assignment,
269 // copy works only if the tails are exactly the same type, ...)
271 cons(typename access_traits<stored_head_type>::parameter_type h,
273 : head (h), tail(t) {}
275 template <class T1, class T2, class T3, class T4, class T5,
276 class T6, class T7, class T8, class T9, class T10>
277 cons( T1& t1, T2& t2, T3& t3, T4& t4, T5& t5,
278 T6& t6, T7& t7, T8& t8, T9& t9, T10& t10 )
280 tail (t2, t3, t4, t5, t6, t7, t8, t9, t10, detail::cnull())
283 template <class T2, class T3, class T4, class T5,
284 class T6, class T7, class T8, class T9, class T10>
285 cons( const null_type& t1, T2& t2, T3& t3, T4& t4, T5& t5,
286 T6& t6, T7& t7, T8& t8, T9& t9, T10& t10 )
288 tail (t2, t3, t4, t5, t6, t7, t8, t9, t10, detail::cnull())
292 template <class HT2, class TT2>
293 cons( const cons<HT2, TT2>& u ) : head(u.head), tail(u.tail) {}
295 template <class HT2, class TT2>
296 cons& operator=( const cons<HT2, TT2>& u ) {
297 head=u.head; tail=u.tail; return *this;
300 // must define assignment operator explicitly, implicit version is
301 // illformed if HT is a reference (12.8. (12))
302 cons& operator=(const cons& u) {
303 head = u.head; tail = u.tail; return *this;
306 template <class T1, class T2>
307 cons& operator=( const std::pair<T1, T2>& u ) {
308 BOOST_STATIC_ASSERT(length<cons>::value == 2); // check length = 2
309 head = u.first; tail.head = u.second; return *this;
312 // get member functions (non-const and const)
314 typename access_traits<
315 typename element<N, cons<HT, TT> >::type
318 return boost::tuples::get<N>(*this); // delegate to non-member get
322 typename access_traits<
323 typename element<N, cons<HT, TT> >::type
326 return boost::tuples::get<N>(*this); // delegate to non-member get
331 struct cons<HT, null_type> {
333 typedef HT head_type;
334 typedef null_type tail_type;
337 detail::wrap_non_storeable_type<head_type>::type stored_head_type;
338 stored_head_type head;
340 typename access_traits<stored_head_type>::non_const_type
341 get_head() { return head; }
343 null_type get_tail() { return null_type(); }
345 typename access_traits<stored_head_type>::const_type
346 get_head() const { return head; }
348 const null_type get_tail() const { return null_type(); }
350 // cons() : head(detail::default_arg<HT>::f()) {}
353 cons(typename access_traits<stored_head_type>::parameter_type h,
354 const null_type& = null_type())
358 cons(T1& t1, const null_type&, const null_type&, const null_type&,
359 const null_type&, const null_type&, const null_type&,
360 const null_type&, const null_type&, const null_type&)
363 cons(const null_type& t1,
364 const null_type&, const null_type&, const null_type&,
365 const null_type&, const null_type&, const null_type&,
366 const null_type&, const null_type&, const null_type&)
370 cons( const cons<HT2, null_type>& u ) : head(u.head) {}
373 cons& operator=(const cons<HT2, null_type>& u )
374 { head = u.head; return *this; }
376 // must define assignment operator explicitely, implicit version
377 // is illformed if HT is a reference
378 cons& operator=(const cons& u) { head = u.head; return *this; }
381 typename access_traits<
382 typename element<N, cons>::type
384 get(BOOST_TUPLE_SINGLE_DUMMY_PARM) {
385 return boost::tuples::get<N>(*this);
389 typename access_traits<
390 typename element<N, cons>::type
392 get(BOOST_TUPLE_SINGLE_DUMMY_PARM) const {
393 return boost::tuples::get<N>(*this);
398 // templates for finding out the length of the tuple -------------------
402 BOOST_STATIC_CONSTANT(int, value = 1 + length<typename T::tail_type>::value);
406 struct length<tuple<> > {
407 BOOST_STATIC_CONSTANT(int, value = 0);
411 struct length<null_type> {
412 BOOST_STATIC_CONSTANT(int, value = 0);
418 // Tuple to cons mapper --------------------------------------------------
419 template <class T0, class T1, class T2, class T3, class T4,
420 class T5, class T6, class T7, class T8, class T9>
421 struct map_tuple_to_cons
424 typename map_tuple_to_cons<T1, T2, T3, T4, T5,
425 T6, T7, T8, T9, null_type>::type
429 // The empty tuple is a null_type
431 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>
433 typedef null_type type;
438 // -------------------------------------------------------------------
439 // -- tuple ------------------------------------------------------
440 template <class T0, class T1, class T2, class T3, class T4,
441 class T5, class T6, class T7, class T8, class T9>
444 public detail::map_tuple_to_cons<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type
448 detail::map_tuple_to_cons<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type inherited;
449 typedef typename inherited::head_type head_type;
450 typedef typename inherited::tail_type tail_type;
453 // access_traits<T>::parameter_type takes non-reference types as const T&
456 tuple(typename access_traits<T0>::parameter_type t0)
457 : inherited(t0, detail::cnull(), detail::cnull(), detail::cnull(),
458 detail::cnull(), detail::cnull(), detail::cnull(),
459 detail::cnull(), detail::cnull(), detail::cnull()) {}
461 tuple(typename access_traits<T0>::parameter_type t0,
462 typename access_traits<T1>::parameter_type t1)
463 : inherited(t0, t1, detail::cnull(), detail::cnull(),
464 detail::cnull(), detail::cnull(), detail::cnull(),
465 detail::cnull(), detail::cnull(), detail::cnull()) {}
467 tuple(typename access_traits<T0>::parameter_type t0,
468 typename access_traits<T1>::parameter_type t1,
469 typename access_traits<T2>::parameter_type t2)
470 : inherited(t0, t1, t2, detail::cnull(), detail::cnull(),
471 detail::cnull(), detail::cnull(), detail::cnull(),
472 detail::cnull(), detail::cnull()) {}
474 tuple(typename access_traits<T0>::parameter_type t0,
475 typename access_traits<T1>::parameter_type t1,
476 typename access_traits<T2>::parameter_type t2,
477 typename access_traits<T3>::parameter_type t3)
478 : inherited(t0, t1, t2, t3, detail::cnull(), detail::cnull(),
479 detail::cnull(), detail::cnull(), detail::cnull(),
482 tuple(typename access_traits<T0>::parameter_type t0,
483 typename access_traits<T1>::parameter_type t1,
484 typename access_traits<T2>::parameter_type t2,
485 typename access_traits<T3>::parameter_type t3,
486 typename access_traits<T4>::parameter_type t4)
487 : inherited(t0, t1, t2, t3, t4, detail::cnull(), detail::cnull(),
488 detail::cnull(), detail::cnull(), detail::cnull()) {}
490 tuple(typename access_traits<T0>::parameter_type t0,
491 typename access_traits<T1>::parameter_type t1,
492 typename access_traits<T2>::parameter_type t2,
493 typename access_traits<T3>::parameter_type t3,
494 typename access_traits<T4>::parameter_type t4,
495 typename access_traits<T5>::parameter_type t5)
496 : inherited(t0, t1, t2, t3, t4, t5, detail::cnull(), detail::cnull(),
497 detail::cnull(), detail::cnull()) {}
499 tuple(typename access_traits<T0>::parameter_type t0,
500 typename access_traits<T1>::parameter_type t1,
501 typename access_traits<T2>::parameter_type t2,
502 typename access_traits<T3>::parameter_type t3,
503 typename access_traits<T4>::parameter_type t4,
504 typename access_traits<T5>::parameter_type t5,
505 typename access_traits<T6>::parameter_type t6)
506 : inherited(t0, t1, t2, t3, t4, t5, t6, detail::cnull(),
507 detail::cnull(), detail::cnull()) {}
509 tuple(typename access_traits<T0>::parameter_type t0,
510 typename access_traits<T1>::parameter_type t1,
511 typename access_traits<T2>::parameter_type t2,
512 typename access_traits<T3>::parameter_type t3,
513 typename access_traits<T4>::parameter_type t4,
514 typename access_traits<T5>::parameter_type t5,
515 typename access_traits<T6>::parameter_type t6,
516 typename access_traits<T7>::parameter_type t7)
517 : inherited(t0, t1, t2, t3, t4, t5, t6, t7, detail::cnull(),
520 tuple(typename access_traits<T0>::parameter_type t0,
521 typename access_traits<T1>::parameter_type t1,
522 typename access_traits<T2>::parameter_type t2,
523 typename access_traits<T3>::parameter_type t3,
524 typename access_traits<T4>::parameter_type t4,
525 typename access_traits<T5>::parameter_type t5,
526 typename access_traits<T6>::parameter_type t6,
527 typename access_traits<T7>::parameter_type t7,
528 typename access_traits<T8>::parameter_type t8)
529 : inherited(t0, t1, t2, t3, t4, t5, t6, t7, t8, detail::cnull()) {}
531 tuple(typename access_traits<T0>::parameter_type t0,
532 typename access_traits<T1>::parameter_type t1,
533 typename access_traits<T2>::parameter_type t2,
534 typename access_traits<T3>::parameter_type t3,
535 typename access_traits<T4>::parameter_type t4,
536 typename access_traits<T5>::parameter_type t5,
537 typename access_traits<T6>::parameter_type t6,
538 typename access_traits<T7>::parameter_type t7,
539 typename access_traits<T8>::parameter_type t8,
540 typename access_traits<T9>::parameter_type t9)
541 : inherited(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) {}
544 template<class U1, class U2>
545 tuple(const cons<U1, U2>& p) : inherited(p) {}
547 template <class U1, class U2>
548 tuple& operator=(const cons<U1, U2>& k) {
549 inherited::operator=(k);
553 template <class U1, class U2>
554 tuple& operator=(const std::pair<U1, U2>& k) {
555 BOOST_STATIC_ASSERT(length<tuple>::value == 2);// check_length = 2
556 this->head = k.first;
557 this->tail.head = k.second;
565 class tuple<null_type, null_type, null_type, null_type, null_type, null_type, null_type, null_type, null_type, null_type> :
569 typedef null_type inherited;
573 // Swallows any assignment (by Doug Gregor)
576 struct swallow_assign {
579 swallow_assign& operator=(const T&) {
584 } // namespace detail
586 // "ignore" allows tuple positions to be ignored when using "tie".
588 detail::swallow_assign ignore;
591 // ---------------------------------------------------------------------------
592 // The call_traits for make_tuple
593 // Honours the reference_wrapper class.
595 // Must be instantiated with plain or const plain types (not with references)
597 // from template<class T> foo(const T& t) : make_tuple_traits<const T>::type
598 // from template<class T> foo(T& t) : make_tuple_traits<T>::type
602 // references -> compile_time_error
603 // reference_wrapper<T> -> T&
604 // const reference_wrapper<T> -> T&
605 // array -> const ref array
609 struct make_tuple_traits {
612 // commented away, see below (JJ)
613 // typedef typename IF<
614 // boost::is_function<T>::value,
620 // The is_function test was there originally for plain function types,
621 // which can't be stored as such (we must either store them as references or
622 // pointers). Such a type could be formed if make_tuple was called with a
623 // reference to a function.
624 // But this would mean that a const qualified function type was formed in
625 // the make_tuple function and hence make_tuple can't take a function
626 // reference as a parameter, and thus T can't be a function type.
627 // So is_function test was removed.
628 // (14.8.3. says that type deduction fails if a cv-qualified function type
629 // is created. (It only applies for the case of explicitly specifying template
630 // args, though?)) (JJ)
633 struct make_tuple_traits<T&> {
635 detail::generate_error<T&>::
636 do_not_use_with_reference_type error;
639 // Arrays can't be stored as plain types; convert them to references.
640 // All arrays are converted to const. This is because make_tuple takes its
641 // parameters as const T& and thus the knowledge of the potential
642 // non-constness of actual argument is lost.
643 template<class T, int n> struct make_tuple_traits <T[n]> {
644 typedef const T (&type)[n];
647 template<class T, int n>
648 struct make_tuple_traits<const T[n]> {
649 typedef const T (&type)[n];
652 template<class T, int n> struct make_tuple_traits<volatile T[n]> {
653 typedef const volatile T (&type)[n];
656 template<class T, int n>
657 struct make_tuple_traits<const volatile T[n]> {
658 typedef const volatile T (&type)[n];
662 struct make_tuple_traits<reference_wrapper<T> >{
667 struct make_tuple_traits<const reference_wrapper<T> >{
676 // a helper traits to make the make_tuple functions shorter (Vesa Karvonen's
679 class T0 = null_type, class T1 = null_type, class T2 = null_type,
680 class T3 = null_type, class T4 = null_type, class T5 = null_type,
681 class T6 = null_type, class T7 = null_type, class T8 = null_type,
684 struct make_tuple_mapper {
686 tuple<typename make_tuple_traits<T0>::type,
687 typename make_tuple_traits<T1>::type,
688 typename make_tuple_traits<T2>::type,
689 typename make_tuple_traits<T3>::type,
690 typename make_tuple_traits<T4>::type,
691 typename make_tuple_traits<T5>::type,
692 typename make_tuple_traits<T6>::type,
693 typename make_tuple_traits<T7>::type,
694 typename make_tuple_traits<T8>::type,
695 typename make_tuple_traits<T9>::type> type;
700 // -make_tuple function templates -----------------------------------
701 inline tuple<> make_tuple() {
706 inline typename detail::make_tuple_mapper<T0>::type
707 make_tuple(const T0& t0) {
708 typedef typename detail::make_tuple_mapper<T0>::type t;
712 template<class T0, class T1>
713 inline typename detail::make_tuple_mapper<T0, T1>::type
714 make_tuple(const T0& t0, const T1& t1) {
715 typedef typename detail::make_tuple_mapper<T0, T1>::type t;
719 template<class T0, class T1, class T2>
720 inline typename detail::make_tuple_mapper<T0, T1, T2>::type
721 make_tuple(const T0& t0, const T1& t1, const T2& t2) {
722 typedef typename detail::make_tuple_mapper<T0, T1, T2>::type t;
723 return t(t0, t1, t2);
726 template<class T0, class T1, class T2, class T3>
727 inline typename detail::make_tuple_mapper<T0, T1, T2, T3>::type
728 make_tuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3) {
729 typedef typename detail::make_tuple_mapper<T0, T1, T2, T3>::type t;
730 return t(t0, t1, t2, t3);
733 template<class T0, class T1, class T2, class T3, class T4>
734 inline typename detail::make_tuple_mapper<T0, T1, T2, T3, T4>::type
735 make_tuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3,
737 typedef typename detail::make_tuple_mapper<T0, T1, T2, T3, T4>::type t;
738 return t(t0, t1, t2, t3, t4);
741 template<class T0, class T1, class T2, class T3, class T4, class T5>
742 inline typename detail::make_tuple_mapper<T0, T1, T2, T3, T4, T5>::type
743 make_tuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3,
744 const T4& t4, const T5& t5) {
745 typedef typename detail::make_tuple_mapper<T0, T1, T2, T3, T4, T5>::type t;
746 return t(t0, t1, t2, t3, t4, t5);
749 template<class T0, class T1, class T2, class T3, class T4, class T5, class T6>
750 inline typename detail::make_tuple_mapper<T0, T1, T2, T3, T4, T5, T6>::type
751 make_tuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3,
752 const T4& t4, const T5& t5, const T6& t6) {
753 typedef typename detail::make_tuple_mapper
754 <T0, T1, T2, T3, T4, T5, T6>::type t;
755 return t(t0, t1, t2, t3, t4, t5, t6);
758 template<class T0, class T1, class T2, class T3, class T4, class T5, class T6,
760 inline typename detail::make_tuple_mapper<T0, T1, T2, T3, T4, T5, T6, T7>::type
761 make_tuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3,
762 const T4& t4, const T5& t5, const T6& t6, const T7& t7) {
763 typedef typename detail::make_tuple_mapper
764 <T0, T1, T2, T3, T4, T5, T6, T7>::type t;
765 return t(t0, t1, t2, t3, t4, t5, t6, t7);
768 template<class T0, class T1, class T2, class T3, class T4, class T5, class T6,
770 inline typename detail::make_tuple_mapper
771 <T0, T1, T2, T3, T4, T5, T6, T7, T8>::type
772 make_tuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3,
773 const T4& t4, const T5& t5, const T6& t6, const T7& t7,
775 typedef typename detail::make_tuple_mapper
776 <T0, T1, T2, T3, T4, T5, T6, T7, T8>::type t;
777 return t(t0, t1, t2, t3, t4, t5, t6, t7, t8);
780 template<class T0, class T1, class T2, class T3, class T4, class T5, class T6,
781 class T7, class T8, class T9>
782 inline typename detail::make_tuple_mapper
783 <T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type
784 make_tuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3,
785 const T4& t4, const T5& t5, const T6& t6, const T7& t7,
786 const T8& t8, const T9& t9) {
787 typedef typename detail::make_tuple_mapper
788 <T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type t;
789 return t(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9);
794 // Tie function templates -------------------------------------------------
796 inline tuple<T1&> tie(T1& t1) {
797 return tuple<T1&> (t1);
800 template<class T1, class T2>
801 inline tuple<T1&, T2&> tie(T1& t1, T2& t2) {
802 return tuple<T1&, T2&> (t1, t2);
805 template<class T1, class T2, class T3>
806 inline tuple<T1&, T2&, T3&> tie(T1& t1, T2& t2, T3& t3) {
807 return tuple<T1&, T2&, T3&> (t1, t2, t3);
810 template<class T1, class T2, class T3, class T4>
811 inline tuple<T1&, T2&, T3&, T4&> tie(T1& t1, T2& t2, T3& t3, T4& t4) {
812 return tuple<T1&, T2&, T3&, T4&> (t1, t2, t3, t4);
815 template<class T1, class T2, class T3, class T4, class T5>
816 inline tuple<T1&, T2&, T3&, T4&, T5&>
817 tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5) {
818 return tuple<T1&, T2&, T3&, T4&, T5&> (t1, t2, t3, t4, t5);
821 template<class T1, class T2, class T3, class T4, class T5, class T6>
822 inline tuple<T1&, T2&, T3&, T4&, T5&, T6&>
823 tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6) {
824 return tuple<T1&, T2&, T3&, T4&, T5&, T6&> (t1, t2, t3, t4, t5, t6);
827 template<class T1, class T2, class T3, class T4, class T5, class T6, class T7>
828 inline tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&>
829 tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7) {
830 return tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&> (t1, t2, t3, t4, t5, t6, t7);
833 template<class T1, class T2, class T3, class T4, class T5, class T6, class T7,
835 inline tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&>
836 tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8) {
837 return tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&>
838 (t1, t2, t3, t4, t5, t6, t7, t8);
841 template<class T1, class T2, class T3, class T4, class T5, class T6, class T7,
843 inline tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&, T9&>
844 tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8,
846 return tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&, T9&>
847 (t1, t2, t3, t4, t5, t6, t7, t8, t9);
850 template<class T1, class T2, class T3, class T4, class T5, class T6, class T7,
851 class T8, class T9, class T10>
852 inline tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&, T9&, T10&>
853 tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8,
855 return tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&, T9&, T10&>
856 (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10);
859 } // end of namespace tuples
860 } // end of namespace boost
862 #undef BOOST_TUPLE_DUMMY_PARM
863 #undef BOOST_TUPLE_SINGLE_DUMMY_PARM
865 #endif // BOOST_TUPLE_BASIC_HPP