source: NonGTP/Boost/boost/spirit/phoenix/tuples.hpp @ 857

Revision 857, 42.6 KB checked in by igarcia, 19 years ago (diff)
Line 
1/*=============================================================================
2    Phoenix V1.2.1
3    Copyright (c) 2001-2002 Joel de Guzman
4
5    Use, modification and distribution is subject to the Boost Software
6    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7    http://www.boost.org/LICENSE_1_0.txt)
8==============================================================================*/
9#ifndef PHOENIX_TUPLES_HPP
10#define PHOENIX_TUPLES_HPP
11
12#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)
13#error "Sorry, Phoenix does not support VC6 and VC7. Please upgrade to at least VC7.1"
14#endif
15
16///////////////////////////////////////////////////////////////////////////////
17//
18//  Phoenix predefined maximum limit. This limit defines the maximum
19//  number of elements a tuple can hold. This number defaults to 3. The
20//  actual maximum is rounded up in multiples of 3. Thus, if this value
21//  is 4, the actual limit is 6. The ultimate maximum limit in this
22//  implementation is 15.
23//
24///////////////////////////////////////////////////////////////////////////////
25#ifndef PHOENIX_LIMIT
26#define PHOENIX_LIMIT 3
27#endif
28
29#if defined(__BORLANDC__) && (__BORLANDC__ <= 0x561)
30namespace phoenix { namespace borland_only
31{
32    namespace ftors
33    {
34        //  We define these dummy template functions. Borland complains when
35        //  a template class has the same name as a template function,
36        //  regardless if they are in different namespaces.
37
38        template <typename T> void if_(T) {}
39        template <typename T> void for_(T) {}
40        template <typename T> void while_(T) {}
41        template <typename T> void do_(T) {}
42    }
43
44    namespace tmpls
45    {
46        //  We define these dummy template functions. Borland complains when
47        //  a template class has the same name as a template function,
48        //  regardless if they are in different namespaces.
49
50        template <typename T> struct if_ {};
51        template <typename T> struct for_ {};
52        template <typename T> struct while_ {};
53        template <typename T> struct do_ {};
54    }
55
56}} // namespace phoenix::borland_only
57#endif
58
59///////////////////////////////////////////////////////////////////////////////
60#include <boost/static_assert.hpp>
61#include <boost/call_traits.hpp>
62#include <boost/type_traits/remove_reference.hpp>
63
64///////////////////////////////////////////////////////////////////////////////
65namespace phoenix {
66
67///////////////////////////////////////////////////////////////////////////////
68//
69//  tuple
70//
71//      Tuples hold heterogeneous types up to a predefined maximum. Only
72//      the most basic functionality needed is provided. Unlike other
73//      recursive list-like tuple implementations, this tuple
74//      implementation uses simple structs similar to std::pair with
75//      specialization for 0 to N tuple elements.
76//
77//          1)  Construction
78//              Here are examples on how to construct tuples:
79//
80//                  typedef tuple<int, char> t1_t;
81//                  typedef tuple<int, std::string, double> t2_t;
82//
83//                  // this tuple has an int and char members
84//                  t1_t t1(3, 'c');
85//
86//                  // this tuple has an int, std::string and double members
87//                  t2_t t2(3, "hello", 3.14);
88//
89//              Tuples can also be constructed from other tuples. The
90//              source and destination tuples need not have exactly the
91//              same element types. The only requirement is that the
92//              source tuple have the same number of elements as the
93//              destination and that each element slot in the
94//              destination can be copy constructed from the source
95//              element. For example:
96//
97//                  tuple<double, double> t3(t1); // OK. Compatible tuples
98//                  tuple<double, double> t4(t2); // Error! Incompatible tuples
99//
100//          2)  Member access
101//                  A member in a tuple can be accessed using the
102//                  tuple's [] operator by specifying the Nth
103//                  tuple_index. Here are some examples:
104//
105//                      tuple_index<0> ix0; // 0th index == 1st item
106//                      tuple_index<1> ix1; // 1st index == 2nd item
107//                      tuple_index<2> ix2; // 2nd index == 3rd item
108//
109//                      t1[ix0] = 33;  // sets the int member of the tuple t1
110//                      t2[ix2] = 6e6; // sets the double member of the tuple t2
111//                      t1[ix1] = 'a'; // sets the char member of the tuple t1
112//
113//                  There are some predefined names are provided in sub-
114//                  namespace tuple_index_names:
115//
116//                      tuple_index<0> _1;
117//                      tuple_index<1> _2;
118//                      ...
119//                      tuple_index<N> _N;
120//
121//                  These indexes may be used by 'using' namespace
122//                  phoenix::tuple_index_names.
123//
124//                  Access to out of bound indexes returns a nil_t value.
125//
126//          3)  Member type inquiry
127//                  The type of an individual member can be queried.
128//                  Example:
129//
130//                      tuple_element<1, t2_t>::type
131//
132//                  Refers to the type of the second member (note zero based,
133//                  thus 0 = 1st item, 1 = 2nd item) of the tuple.
134//
135//                  Aside from tuple_element<N, T>::type, there are two
136//                  more types that tuple_element provides: rtype and
137//                  crtype. While 'type' is the plain underlying type,
138//                  'rtype' is the reference type, or type& and 'crtype'
139//                  is the constant reference type or type const&. The
140//                  latter two are provided to make it easy for the
141//                  client in dealing with the possibility of reference
142//                  to reference when type is already a reference, which
143//                  is illegal in C++.
144//
145//                  Access to out of bound indexes returns a nil_t type.
146//
147//          4)  Tuple length
148//                  The number of elements in a tuple can be queried.
149//                  Example:
150//
151//                      int n = t1.length;
152//
153//                  gets the number of elements in tuple t1.
154//
155//                  length is a static constant. Thus, TupleT::length
156//                  also works. Example:
157//
158//                      int n = t1_t::length;
159//
160///////////////////////////////////////////////////////////////////////////////
161struct nil_t {};
162using boost::remove_reference;
163using boost::call_traits;
164
165//////////////////////////////////
166namespace impl {
167
168    template <typename T>
169    struct access {
170
171        typedef const T& ctype;
172        typedef T& type;
173    };
174
175    template <typename T>
176    struct access<T&> {
177
178        typedef T& ctype;
179        typedef T& type;
180    };
181}
182
183///////////////////////////////////////////////////////////////////////////////
184//
185//  tuple_element
186//
187//      A query class that gets the Nth element inside a tuple.
188//      Examples:
189//
190//          tuple_element<1, tuple<int, char, void*> >::type    //  plain
191//          tuple_element<1, tuple<int, char, void*> >::rtype   //  ref
192//          tuple_element<1, tuple<int, char, void*> >::crtype  //  const ref
193//
194//      Has type char which is the 2nd type in the tuple
195//      (note zero based, thus 0 = 1st item, 1 = 2nd item).
196//
197//          Given a tuple object, the static function tuple_element<N,
198//          TupleT>::get(tuple) gets the Nth element in the tuple. The
199//          tuple class' tuple::operator[] uses this to get its Nth
200//          element.
201//
202///////////////////////////////////////////////////////////////////////////////
203template <int N, typename TupleT>
204struct tuple_element
205{
206    typedef nil_t type;
207    typedef nil_t& rtype;
208    typedef nil_t const& crtype;
209
210    static nil_t    get(TupleT const& t)    { return nil_t(); }
211};
212
213//////////////////////////////////
214template <typename TupleT>
215struct tuple_element<0, TupleT>
216{
217    typedef typename TupleT::a_type type;
218    typedef typename impl::access<type>::type rtype;
219    typedef typename impl::access<type>::ctype crtype;
220
221    static rtype    get(TupleT& t)          { return t.a; }
222    static crtype   get(TupleT const& t)    { return t.a; }
223};
224
225//////////////////////////////////
226template <typename TupleT>
227struct tuple_element<1, TupleT>
228{
229    typedef typename TupleT::b_type type;
230    typedef typename impl::access<type>::type rtype;
231    typedef typename impl::access<type>::ctype crtype;
232
233    static rtype    get(TupleT& t)          { return t.b; }
234    static crtype   get(TupleT const& t)    { return t.b; }
235};
236
237//////////////////////////////////
238template <typename TupleT>
239struct tuple_element<2, TupleT>
240{
241    typedef typename TupleT::c_type type;
242    typedef typename impl::access<type>::type rtype;
243    typedef typename impl::access<type>::ctype crtype;
244
245    static rtype    get(TupleT& t)          { return t.c; }
246    static crtype   get(TupleT const& t)    { return t.c; }
247};
248
249#if PHOENIX_LIMIT > 3
250//////////////////////////////////
251template <typename TupleT>
252struct tuple_element<3, TupleT>
253{
254    typedef typename TupleT::d_type type;
255    typedef typename impl::access<type>::type rtype;
256    typedef typename impl::access<type>::ctype crtype;
257
258    static rtype    get(TupleT& t)          { return t.d; }
259    static crtype   get(TupleT const& t)    { return t.d; }
260};
261
262//////////////////////////////////
263template <typename TupleT>
264struct tuple_element<4, TupleT>
265{
266    typedef typename TupleT::e_type type;
267    typedef typename impl::access<type>::type rtype;
268    typedef typename impl::access<type>::ctype crtype;
269
270    static rtype    get(TupleT& t)          { return t.e; }
271    static crtype   get(TupleT const& t)    { return t.e; }
272};
273
274//////////////////////////////////
275template <typename TupleT>
276struct tuple_element<5, TupleT>
277{
278    typedef typename TupleT::f_type type;
279    typedef typename impl::access<type>::type rtype;
280    typedef typename impl::access<type>::ctype crtype;
281
282    static rtype    get(TupleT& t)          { return t.f; }
283    static crtype   get(TupleT const& t)    { return t.f; }
284};
285
286#if PHOENIX_LIMIT > 6
287//////////////////////////////////
288template <typename TupleT>
289struct tuple_element<6, TupleT>
290{
291    typedef typename TupleT::g_type type;
292    typedef typename impl::access<type>::type rtype;
293    typedef typename impl::access<type>::ctype crtype;
294
295    static rtype    get(TupleT& t)          { return t.g; }
296    static crtype   get(TupleT const& t)    { return t.g; }
297};
298
299//////////////////////////////////
300template <typename TupleT>
301struct tuple_element<7, TupleT>
302{
303    typedef typename TupleT::h_type type;
304    typedef typename impl::access<type>::type rtype;
305    typedef typename impl::access<type>::ctype crtype;
306
307    static rtype    get(TupleT& t)          { return t.h; }
308    static crtype   get(TupleT const& t)    { return t.h; }
309};
310
311//////////////////////////////////
312template <typename TupleT>
313struct tuple_element<8, TupleT>
314{
315    typedef typename TupleT::i_type type;
316    typedef typename impl::access<type>::type rtype;
317    typedef typename impl::access<type>::ctype crtype;
318
319    static rtype    get(TupleT& t)          { return t.i; }
320    static crtype   get(TupleT const& t)    { return t.i; }
321};
322
323#if PHOENIX_LIMIT > 9
324//////////////////////////////////
325template <typename TupleT>
326struct tuple_element<9, TupleT>
327{
328    typedef typename TupleT::j_type type;
329    typedef typename impl::access<type>::type rtype;
330    typedef typename impl::access<type>::ctype crtype;
331
332    static rtype    get(TupleT& t)          { return t.j; }
333    static crtype   get(TupleT const& t)    { return t.j; }
334};
335
336//////////////////////////////////
337template <typename TupleT>
338struct tuple_element<10, TupleT>
339{
340    typedef typename TupleT::k_type type;
341    typedef typename impl::access<type>::type rtype;
342    typedef typename impl::access<type>::ctype crtype;
343
344    static rtype    get(TupleT& t)          { return t.k; }
345    static crtype   get(TupleT const& t)    { return t.k; }
346};
347
348//////////////////////////////////
349template <typename TupleT>
350struct tuple_element<11, TupleT>
351{
352    typedef typename TupleT::l_type type;
353    typedef typename impl::access<type>::type rtype;
354    typedef typename impl::access<type>::ctype crtype;
355
356    static rtype    get(TupleT& t)          { return t.l; }
357    static crtype   get(TupleT const& t)    { return t.l; }
358};
359
360#if PHOENIX_LIMIT > 12
361//////////////////////////////////
362template <typename TupleT>
363struct tuple_element<12, TupleT>
364{
365    typedef typename TupleT::m_type type;
366    typedef typename impl::access<type>::type rtype;
367    typedef typename impl::access<type>::ctype crtype;
368
369    static rtype    get(TupleT& t)          { return t.m; }
370    static crtype   get(TupleT const& t)    { return t.m; }
371};
372
373//////////////////////////////////
374template <typename TupleT>
375struct tuple_element<13, TupleT>
376{
377    typedef typename TupleT::n_type type;
378    typedef typename impl::access<type>::type rtype;
379    typedef typename impl::access<type>::ctype crtype;
380
381    static rtype    get(TupleT& t)          { return t.n; }
382    static crtype   get(TupleT const& t)    { return t.n; }
383};
384
385//////////////////////////////////
386template <typename TupleT>
387struct tuple_element<14, TupleT>
388{
389    typedef typename TupleT::o_type type;
390    typedef typename impl::access<type>::type rtype;
391    typedef typename impl::access<type>::ctype crtype;
392
393    static rtype    get(TupleT& t)          { return t.o; }
394    static crtype   get(TupleT const& t)    { return t.o; }
395};
396
397#endif
398#endif
399#endif
400#endif
401
402///////////////////////////////////////////////////////////////////////////////
403//
404//  tuple forward declaration.
405//
406///////////////////////////////////////////////////////////////////////////////
407template <
408        typename A = nil_t
409    ,   typename B = nil_t
410    ,   typename C = nil_t
411
412#if PHOENIX_LIMIT > 3
413    ,   typename D = nil_t
414    ,   typename E = nil_t
415    ,   typename F = nil_t
416
417#if PHOENIX_LIMIT > 6
418    ,   typename G = nil_t
419    ,   typename H = nil_t
420    ,   typename I = nil_t
421
422#if PHOENIX_LIMIT > 9
423    ,   typename J = nil_t
424    ,   typename K = nil_t
425    ,   typename L = nil_t
426
427#if PHOENIX_LIMIT > 12
428    ,   typename M = nil_t
429    ,   typename N = nil_t
430    ,   typename O = nil_t
431
432#endif
433#endif
434#endif
435#endif
436
437    ,   typename NU = nil_t  // Not used
438>
439struct tuple;
440
441///////////////////////////////////////////////////////////////////////////////
442//
443//  tuple_index
444//
445//      This class wraps an integer in a type to be used for indexing
446//      the Nth element in a tuple. See tuple operator[]. Some
447//      predefined names are provided in sub-namespace
448//      tuple_index_names.
449//
450///////////////////////////////////////////////////////////////////////////////
451template <int N>
452struct tuple_index {};
453
454//////////////////////////////////
455namespace tuple_index_names {
456
457    tuple_index<0> const _1 = tuple_index<0>();
458    tuple_index<1> const _2 = tuple_index<1>();
459    tuple_index<2> const _3 = tuple_index<2>();
460
461#if PHOENIX_LIMIT > 3
462    tuple_index<3> const _4 = tuple_index<3>();
463    tuple_index<4> const _5 = tuple_index<4>();
464    tuple_index<5> const _6 = tuple_index<5>();
465
466#if PHOENIX_LIMIT > 6
467    tuple_index<6> const _7 = tuple_index<6>();
468    tuple_index<7> const _8 = tuple_index<7>();
469    tuple_index<8> const _9 = tuple_index<8>();
470
471#if PHOENIX_LIMIT > 9
472    tuple_index<9> const _10 = tuple_index<9>();
473    tuple_index<10> const _11 = tuple_index<10>();
474    tuple_index<11> const _12 = tuple_index<11>();
475
476#if PHOENIX_LIMIT > 12
477    tuple_index<12> const _13 = tuple_index<12>();
478    tuple_index<13> const _14 = tuple_index<13>();
479    tuple_index<14> const _15 = tuple_index<14>();
480
481#endif
482#endif
483#endif
484#endif
485}
486
487///////////////////////////////////////////////////////////////////////////////
488//
489//  tuple_common class
490//
491///////////////////////////////////////////////////////////////////////////////
492template <typename DerivedT>
493struct tuple_base {
494
495    typedef nil_t   a_type;
496    typedef nil_t   b_type;
497    typedef nil_t   c_type;
498
499#if PHOENIX_LIMIT > 3
500    typedef nil_t   d_type;
501    typedef nil_t   e_type;
502    typedef nil_t   f_type;
503
504#if PHOENIX_LIMIT > 6
505    typedef nil_t   g_type;
506    typedef nil_t   h_type;
507    typedef nil_t   i_type;
508
509#if PHOENIX_LIMIT > 9
510    typedef nil_t   j_type;
511    typedef nil_t   k_type;
512    typedef nil_t   l_type;
513
514#if PHOENIX_LIMIT > 12
515    typedef nil_t   m_type;
516    typedef nil_t   n_type;
517    typedef nil_t   o_type;
518
519#endif
520#endif
521#endif
522#endif
523
524    template <int N>
525    typename tuple_element<N, DerivedT>::crtype
526    operator[](tuple_index<N>) const
527    {
528        return tuple_element<N, DerivedT>
529            ::get(*static_cast<DerivedT const*>(this));
530    }
531
532    template <int N>
533    typename tuple_element<N, DerivedT>::rtype
534    operator[](tuple_index<N>)
535    {
536        return tuple_element<N, DerivedT>
537            ::get(*static_cast<DerivedT*>(this));
538    }
539};
540
541///////////////////////////////////////////////////////////////////////////////
542//
543//  tuple <0 member> class
544//
545///////////////////////////////////////////////////////////////////////////////
546template <>
547struct tuple<>
548:   public tuple_base<tuple<> > {
549
550    BOOST_STATIC_CONSTANT(int, length = 0);
551};
552
553///////////////////////////////////////////////////////////////////////////////
554//
555//  tuple <1 member> class
556//
557///////////////////////////////////////////////////////////////////////////////
558template <typename A>
559struct tuple<A, nil_t, nil_t,
560#if PHOENIX_LIMIT > 3
561    nil_t, nil_t, nil_t,
562#if PHOENIX_LIMIT > 6
563    nil_t, nil_t, nil_t,
564#if PHOENIX_LIMIT > 9
565    nil_t, nil_t, nil_t,
566#if PHOENIX_LIMIT > 12
567    nil_t, nil_t, nil_t,
568#endif
569#endif
570#endif
571#endif
572    nil_t   //  Unused
573>
574:   public tuple_base<tuple<A> > {
575
576    BOOST_STATIC_CONSTANT(int, length = 1);
577    typedef A a_type;
578
579    tuple() {}
580
581    tuple(
582        typename call_traits<A>::param_type a_
583    ):  a(a_) {}
584
585    template <typename TupleT>
586    tuple(TupleT const& init)
587    :   a(init[tuple_index<0>()])
588    { BOOST_STATIC_ASSERT(TupleT::length == length); }
589
590    A a;
591};
592
593///////////////////////////////////////////////////////////////////////////////
594//
595//  tuple <2 member> class
596//
597///////////////////////////////////////////////////////////////////////////////
598template <typename A, typename B>
599struct tuple<A, B, nil_t,
600#if PHOENIX_LIMIT > 3
601    nil_t, nil_t, nil_t,
602#if PHOENIX_LIMIT > 6
603    nil_t, nil_t, nil_t,
604#if PHOENIX_LIMIT > 9
605    nil_t, nil_t, nil_t,
606#if PHOENIX_LIMIT > 12
607    nil_t, nil_t, nil_t,
608#endif
609#endif
610#endif
611#endif
612    nil_t   //  Unused
613>
614:   public tuple_base<tuple<A, B> > {
615
616    BOOST_STATIC_CONSTANT(int, length = 2);
617    typedef A a_type; typedef B b_type;
618
619    tuple() {}
620
621    tuple(
622        typename call_traits<A>::param_type a_,
623        typename call_traits<B>::param_type b_
624    ):  a(a_), b(b_) {}
625
626    template <typename TupleT>
627    tuple(TupleT const& init)
628    :   a(init[tuple_index<0>()]), b(init[tuple_index<1>()])
629    { BOOST_STATIC_ASSERT(TupleT::length == length); }
630
631    A a; B b;
632};
633
634///////////////////////////////////////////////////////////////////////////////
635//
636//  tuple <3 member> class
637//
638///////////////////////////////////////////////////////////////////////////////
639template <typename A, typename B, typename C>
640struct tuple<A, B, C,
641#if PHOENIX_LIMIT > 3
642    nil_t, nil_t, nil_t,
643#if PHOENIX_LIMIT > 6
644    nil_t, nil_t, nil_t,
645#if PHOENIX_LIMIT > 9
646    nil_t, nil_t, nil_t,
647#if PHOENIX_LIMIT > 12
648    nil_t, nil_t, nil_t,
649#endif
650#endif
651#endif
652#endif
653    nil_t   //  Unused
654>
655:   public tuple_base<tuple<A, B, C> > {
656
657    BOOST_STATIC_CONSTANT(int, length = 3);
658    typedef A a_type; typedef B b_type;
659    typedef C c_type;
660
661    tuple() {}
662
663    tuple(
664        typename call_traits<A>::param_type a_,
665        typename call_traits<B>::param_type b_,
666        typename call_traits<C>::param_type c_
667    ):  a(a_), b(b_), c(c_) {}
668
669    template <typename TupleT>
670    tuple(TupleT const& init)
671    :   a(init[tuple_index<0>()]), b(init[tuple_index<1>()]),
672        c(init[tuple_index<2>()])
673    { BOOST_STATIC_ASSERT(TupleT::length == length); }
674
675    A a; B b; C c;
676};
677
678#if PHOENIX_LIMIT > 3
679///////////////////////////////////////////////////////////////////////////////
680//
681//  tuple <4 member> class
682//
683///////////////////////////////////////////////////////////////////////////////
684template <typename A, typename B, typename C, typename D>
685struct tuple<A, B, C, D, nil_t, nil_t,
686#if PHOENIX_LIMIT > 6
687    nil_t, nil_t, nil_t,
688#if PHOENIX_LIMIT > 9
689    nil_t, nil_t, nil_t,
690#if PHOENIX_LIMIT > 12
691    nil_t, nil_t, nil_t,
692#endif
693#endif
694#endif
695    nil_t   //  Unused
696>
697:   public tuple_base<tuple<A, B, C, D> > {
698
699    BOOST_STATIC_CONSTANT(int, length = 4);
700    typedef A a_type; typedef B b_type;
701    typedef C c_type; typedef D d_type;
702
703    tuple() {}
704
705    tuple(
706        typename call_traits<A>::param_type a_,
707        typename call_traits<B>::param_type b_,
708        typename call_traits<C>::param_type c_,
709        typename call_traits<D>::param_type d_
710    ):  a(a_), b(b_), c(c_), d(d_) {}
711
712    template <typename TupleT>
713    tuple(TupleT const& init)
714    :   a(init[tuple_index<0>()]), b(init[tuple_index<1>()]),
715        c(init[tuple_index<2>()]), d(init[tuple_index<3>()])
716    { BOOST_STATIC_ASSERT(TupleT::length == length); }
717
718    A a; B b; C c; D d;
719};
720
721///////////////////////////////////////////////////////////////////////////////
722//
723//  tuple <5 member> class
724//
725///////////////////////////////////////////////////////////////////////////////
726template <typename A, typename B, typename C, typename D, typename E>
727struct tuple<A, B, C, D, E, nil_t,
728#if PHOENIX_LIMIT > 6
729    nil_t, nil_t, nil_t,
730#if PHOENIX_LIMIT > 9
731    nil_t, nil_t, nil_t,
732#if PHOENIX_LIMIT > 12
733    nil_t, nil_t, nil_t,
734#endif
735#endif
736#endif
737    nil_t   //  Unused
738>
739:   public tuple_base<tuple<A, B, C, D, E> > {
740
741    BOOST_STATIC_CONSTANT(int, length = 5);
742    typedef A a_type; typedef B b_type;
743    typedef C c_type; typedef D d_type;
744    typedef E e_type;
745
746    tuple() {}
747
748    tuple(
749        typename call_traits<A>::param_type a_,
750        typename call_traits<B>::param_type b_,
751        typename call_traits<C>::param_type c_,
752        typename call_traits<D>::param_type d_,
753        typename call_traits<E>::param_type e_
754    ):  a(a_), b(b_), c(c_), d(d_), e(e_) {}
755
756    template <typename TupleT>
757    tuple(TupleT const& init)
758    :   a(init[tuple_index<0>()]), b(init[tuple_index<1>()]),
759        c(init[tuple_index<2>()]), d(init[tuple_index<3>()]),
760        e(init[tuple_index<4>()])
761    { BOOST_STATIC_ASSERT(TupleT::length == length); }
762
763    A a; B b; C c; D d; E e;
764};
765
766///////////////////////////////////////////////////////////////////////////////
767//
768//  tuple <6 member> class
769//
770///////////////////////////////////////////////////////////////////////////////
771template <
772    typename A, typename B, typename C, typename D, typename E,
773    typename F>
774struct tuple<A, B, C, D, E, F,
775#if PHOENIX_LIMIT > 6
776    nil_t, nil_t, nil_t,
777#if PHOENIX_LIMIT > 9
778    nil_t, nil_t, nil_t,
779#if PHOENIX_LIMIT > 12
780    nil_t, nil_t, nil_t,
781#endif
782#endif
783#endif
784    nil_t   //  Unused
785>
786:   public tuple_base<tuple<A, B, C, D, E, F> > {
787
788    BOOST_STATIC_CONSTANT(int, length = 6);
789    typedef A a_type; typedef B b_type;
790    typedef C c_type; typedef D d_type;
791    typedef E e_type; typedef F f_type;
792
793    tuple() {}
794
795    tuple(
796        typename call_traits<A>::param_type a_,
797        typename call_traits<B>::param_type b_,
798        typename call_traits<C>::param_type c_,
799        typename call_traits<D>::param_type d_,
800        typename call_traits<E>::param_type e_,
801        typename call_traits<F>::param_type f_
802    ):  a(a_), b(b_), c(c_), d(d_), e(e_),
803        f(f_) {}
804
805    template <typename TupleT>
806    tuple(TupleT const& init)
807    :   a(init[tuple_index<0>()]), b(init[tuple_index<1>()]),
808        c(init[tuple_index<2>()]), d(init[tuple_index<3>()]),
809        e(init[tuple_index<4>()]), f(init[tuple_index<5>()])
810    { BOOST_STATIC_ASSERT(TupleT::length == length); }
811
812    A a; B b; C c; D d; E e;
813    F f;
814};
815
816#if PHOENIX_LIMIT > 6
817///////////////////////////////////////////////////////////////////////////////
818//
819//  tuple <7 member> class
820//
821///////////////////////////////////////////////////////////////////////////////
822template <
823    typename A, typename B, typename C, typename D, typename E,
824    typename F, typename G>
825struct tuple<A, B, C, D, E, F, G, nil_t, nil_t,
826#if PHOENIX_LIMIT > 9
827    nil_t, nil_t, nil_t,
828#if PHOENIX_LIMIT > 12
829    nil_t, nil_t, nil_t,
830#endif
831#endif
832    nil_t   //  Unused
833>
834:   public tuple_base<tuple<A, B, C, D, E, F, G> > {
835
836    BOOST_STATIC_CONSTANT(int, length = 7);
837    typedef A a_type; typedef B b_type;
838    typedef C c_type; typedef D d_type;
839    typedef E e_type; typedef F f_type;
840    typedef G g_type;
841
842    tuple() {}
843
844    tuple(
845        typename call_traits<A>::param_type a_,
846        typename call_traits<B>::param_type b_,
847        typename call_traits<C>::param_type c_,
848        typename call_traits<D>::param_type d_,
849        typename call_traits<E>::param_type e_,
850        typename call_traits<F>::param_type f_,
851        typename call_traits<G>::param_type g_
852    ):  a(a_), b(b_), c(c_), d(d_), e(e_),
853        f(f_), g(g_) {}
854
855    template <typename TupleT>
856    tuple(TupleT const& init)
857    :   a(init[tuple_index<0>()]), b(init[tuple_index<1>()]),
858        c(init[tuple_index<2>()]), d(init[tuple_index<3>()]),
859        e(init[tuple_index<4>()]), f(init[tuple_index<5>()]),
860        g(init[tuple_index<6>()])
861    { BOOST_STATIC_ASSERT(TupleT::length == length); }
862
863    A a; B b; C c; D d; E e;
864    F f; G g;
865};
866
867///////////////////////////////////////////////////////////////////////////////
868//
869//  tuple <8 member> class
870//
871///////////////////////////////////////////////////////////////////////////////
872template <
873    typename A, typename B, typename C, typename D, typename E,
874    typename F, typename G, typename H>
875struct tuple<A, B, C, D, E, F, G, H, nil_t,
876#if PHOENIX_LIMIT > 9
877    nil_t, nil_t, nil_t,
878#if PHOENIX_LIMIT > 12
879    nil_t, nil_t, nil_t,
880#endif
881#endif
882    nil_t   //  Unused
883>
884:   public tuple_base<tuple<A, B, C, D, E, F, G, H> > {
885
886    BOOST_STATIC_CONSTANT(int, length = 8);
887    typedef A a_type; typedef B b_type;
888    typedef C c_type; typedef D d_type;
889    typedef E e_type; typedef F f_type;
890    typedef G g_type; typedef H h_type;
891
892    tuple() {}
893
894    tuple(
895        typename call_traits<A>::param_type a_,
896        typename call_traits<B>::param_type b_,
897        typename call_traits<C>::param_type c_,
898        typename call_traits<D>::param_type d_,
899        typename call_traits<E>::param_type e_,
900        typename call_traits<F>::param_type f_,
901        typename call_traits<G>::param_type g_,
902        typename call_traits<H>::param_type h_
903    ):  a(a_), b(b_), c(c_), d(d_), e(e_),
904        f(f_), g(g_), h(h_) {}
905
906    template <typename TupleT>
907    tuple(TupleT const& init)
908    :   a(init[tuple_index<0>()]), b(init[tuple_index<1>()]),
909        c(init[tuple_index<2>()]), d(init[tuple_index<3>()]),
910        e(init[tuple_index<4>()]), f(init[tuple_index<5>()]),
911        g(init[tuple_index<6>()]), h(init[tuple_index<7>()])
912    { BOOST_STATIC_ASSERT(TupleT::length == length); }
913
914    A a; B b; C c; D d; E e;
915    F f; G g; H h;
916};
917
918///////////////////////////////////////////////////////////////////////////////
919//
920//  tuple <9 member> class
921//
922///////////////////////////////////////////////////////////////////////////////
923template <
924    typename A, typename B, typename C, typename D, typename E,
925    typename F, typename G, typename H, typename I>
926struct tuple<A, B, C, D, E, F, G, H, I,
927#if PHOENIX_LIMIT > 9
928    nil_t, nil_t, nil_t,
929#if PHOENIX_LIMIT > 12
930    nil_t, nil_t, nil_t,
931#endif
932#endif
933    nil_t   //  Unused
934>
935:   public tuple_base<tuple<A, B, C, D, E, F, G, H, I> > {
936
937    BOOST_STATIC_CONSTANT(int, length = 9);
938    typedef A a_type; typedef B b_type;
939    typedef C c_type; typedef D d_type;
940    typedef E e_type; typedef F f_type;
941    typedef G g_type; typedef H h_type;
942    typedef I i_type;
943
944    tuple() {}
945
946    tuple(
947        typename call_traits<A>::param_type a_,
948        typename call_traits<B>::param_type b_,
949        typename call_traits<C>::param_type c_,
950        typename call_traits<D>::param_type d_,
951        typename call_traits<E>::param_type e_,
952        typename call_traits<F>::param_type f_,
953        typename call_traits<G>::param_type g_,
954        typename call_traits<H>::param_type h_,
955        typename call_traits<I>::param_type i_
956    ):  a(a_), b(b_), c(c_), d(d_), e(e_),
957        f(f_), g(g_), h(h_), i(i_) {}
958
959    template <typename TupleT>
960    tuple(TupleT const& init)
961    :   a(init[tuple_index<0>()]), b(init[tuple_index<1>()]),
962        c(init[tuple_index<2>()]), d(init[tuple_index<3>()]),
963        e(init[tuple_index<4>()]), f(init[tuple_index<5>()]),
964        g(init[tuple_index<6>()]), h(init[tuple_index<7>()]),
965        i(init[tuple_index<8>()])
966    { BOOST_STATIC_ASSERT(TupleT::length == length); }
967
968    A a; B b; C c; D d; E e;
969    F f; G g; H h; I i;
970};
971
972#if PHOENIX_LIMIT > 9
973///////////////////////////////////////////////////////////////////////////////
974//
975//  tuple <10 member> class
976//
977///////////////////////////////////////////////////////////////////////////////
978template <
979    typename A, typename B, typename C, typename D, typename E,
980    typename F, typename G, typename H, typename I, typename J>
981struct tuple<A, B, C, D, E, F, G, H, I, J, nil_t, nil_t,
982#if PHOENIX_LIMIT > 12
983    nil_t, nil_t, nil_t,
984#endif
985    nil_t   //  Unused
986>
987:   public tuple_base<tuple<A, B, C, D, E, F, G, H, I, J> > {
988
989    BOOST_STATIC_CONSTANT(int, length = 10);
990    typedef A a_type; typedef B b_type;
991    typedef C c_type; typedef D d_type;
992    typedef E e_type; typedef F f_type;
993    typedef G g_type; typedef H h_type;
994    typedef I i_type; typedef J j_type;
995
996    tuple() {}
997
998    tuple(
999        typename call_traits<A>::param_type a_,
1000        typename call_traits<B>::param_type b_,
1001        typename call_traits<C>::param_type c_,
1002        typename call_traits<D>::param_type d_,
1003        typename call_traits<E>::param_type e_,
1004        typename call_traits<F>::param_type f_,
1005        typename call_traits<G>::param_type g_,
1006        typename call_traits<H>::param_type h_,
1007        typename call_traits<I>::param_type i_,
1008        typename call_traits<J>::param_type j_
1009    ):  a(a_), b(b_), c(c_), d(d_), e(e_),
1010        f(f_), g(g_), h(h_), i(i_), j(j_) {}
1011
1012    template <typename TupleT>
1013    tuple(TupleT const& init)
1014    :   a(init[tuple_index<0>()]), b(init[tuple_index<1>()]),
1015        c(init[tuple_index<2>()]), d(init[tuple_index<3>()]),
1016        e(init[tuple_index<4>()]), f(init[tuple_index<5>()]),
1017        g(init[tuple_index<6>()]), h(init[tuple_index<7>()]),
1018        i(init[tuple_index<8>()]), j(init[tuple_index<9>()])
1019    { BOOST_STATIC_ASSERT(TupleT::length == length); }
1020
1021    A a; B b; C c; D d; E e;
1022    F f; G g; H h; I i; J j;
1023};
1024
1025///////////////////////////////////////////////////////////////////////////////
1026//
1027//  tuple <11 member> class
1028//
1029///////////////////////////////////////////////////////////////////////////////
1030template <
1031    typename A, typename B, typename C, typename D, typename E,
1032    typename F, typename G, typename H, typename I, typename J,
1033    typename K>
1034struct tuple<A, B, C, D, E, F, G, H, I, J, K, nil_t,
1035#if PHOENIX_LIMIT > 12
1036    nil_t, nil_t, nil_t,
1037#endif
1038    nil_t   //  Unused
1039>
1040:   public tuple_base<tuple<A, B, C, D, E, F, G, H, I, J, K> > {
1041
1042    BOOST_STATIC_CONSTANT(int, length = 11);
1043    typedef A a_type; typedef B b_type;
1044    typedef C c_type; typedef D d_type;
1045    typedef E e_type; typedef F f_type;
1046    typedef G g_type; typedef H h_type;
1047    typedef I i_type; typedef J j_type;
1048    typedef K k_type;
1049
1050    tuple() {}
1051
1052    tuple(
1053        typename call_traits<A>::param_type a_,
1054        typename call_traits<B>::param_type b_,
1055        typename call_traits<C>::param_type c_,
1056        typename call_traits<D>::param_type d_,
1057        typename call_traits<E>::param_type e_,
1058        typename call_traits<F>::param_type f_,
1059        typename call_traits<G>::param_type g_,
1060        typename call_traits<H>::param_type h_,
1061        typename call_traits<I>::param_type i_,
1062        typename call_traits<J>::param_type j_,
1063        typename call_traits<K>::param_type k_
1064    ):  a(a_), b(b_), c(c_), d(d_), e(e_),
1065        f(f_), g(g_), h(h_), i(i_), j(j_),
1066        k(k_) {}
1067
1068    template <typename TupleT>
1069    tuple(TupleT const& init)
1070    :   a(init[tuple_index<0>()]), b(init[tuple_index<1>()]),
1071        c(init[tuple_index<2>()]), d(init[tuple_index<3>()]),
1072        e(init[tuple_index<4>()]), f(init[tuple_index<5>()]),
1073        g(init[tuple_index<6>()]), h(init[tuple_index<7>()]),
1074        i(init[tuple_index<8>()]), j(init[tuple_index<9>()]),
1075        k(init[tuple_index<10>()])
1076    { BOOST_STATIC_ASSERT(TupleT::length == length); }
1077
1078    A a; B b; C c; D d; E e;
1079    F f; G g; H h; I i; J j;
1080    K k;
1081};
1082
1083///////////////////////////////////////////////////////////////////////////////
1084//
1085//  tuple <12 member> class
1086//
1087///////////////////////////////////////////////////////////////////////////////
1088template <
1089    typename A, typename B, typename C, typename D, typename E,
1090    typename F, typename G, typename H, typename I, typename J,
1091    typename K, typename L>
1092struct tuple<A, B, C, D, E, F, G, H, I, J, K, L,
1093#if PHOENIX_LIMIT > 12
1094    nil_t, nil_t, nil_t,
1095#endif
1096    nil_t   //  Unused
1097>
1098:   public tuple_base<tuple<A, B, C, D, E, F, G, H, I, J, K, L> > {
1099
1100    BOOST_STATIC_CONSTANT(int, length = 12);
1101    typedef A a_type; typedef B b_type;
1102    typedef C c_type; typedef D d_type;
1103    typedef E e_type; typedef F f_type;
1104    typedef G g_type; typedef H h_type;
1105    typedef I i_type; typedef J j_type;
1106    typedef K k_type; typedef L l_type;
1107
1108    tuple() {}
1109
1110    tuple(
1111        typename call_traits<A>::param_type a_,
1112        typename call_traits<B>::param_type b_,
1113        typename call_traits<C>::param_type c_,
1114        typename call_traits<D>::param_type d_,
1115        typename call_traits<E>::param_type e_,
1116        typename call_traits<F>::param_type f_,
1117        typename call_traits<G>::param_type g_,
1118        typename call_traits<H>::param_type h_,
1119        typename call_traits<I>::param_type i_,
1120        typename call_traits<J>::param_type j_,
1121        typename call_traits<K>::param_type k_,
1122        typename call_traits<L>::param_type l_
1123    ):  a(a_), b(b_), c(c_), d(d_), e(e_),
1124        f(f_), g(g_), h(h_), i(i_), j(j_),
1125        k(k_), l(l_) {}
1126
1127    template <typename TupleT>
1128    tuple(TupleT const& init)
1129    :   a(init[tuple_index<0>()]), b(init[tuple_index<1>()]),
1130        c(init[tuple_index<2>()]), d(init[tuple_index<3>()]),
1131        e(init[tuple_index<4>()]), f(init[tuple_index<5>()]),
1132        g(init[tuple_index<6>()]), h(init[tuple_index<7>()]),
1133        i(init[tuple_index<8>()]), j(init[tuple_index<9>()]),
1134        k(init[tuple_index<10>()]), l(init[tuple_index<11>()])
1135    { BOOST_STATIC_ASSERT(TupleT::length == length); }
1136
1137    A a; B b; C c; D d; E e;
1138    F f; G g; H h; I i; J j;
1139    K k; L l;
1140};
1141
1142#if PHOENIX_LIMIT > 12
1143///////////////////////////////////////////////////////////////////////////////
1144//
1145//  tuple <13 member> class
1146//
1147///////////////////////////////////////////////////////////////////////////////
1148template <
1149    typename A, typename B, typename C, typename D, typename E,
1150    typename F, typename G, typename H, typename I, typename J,
1151    typename K, typename L, typename M>
1152struct tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, nil_t, nil_t, nil_t>
1153:   public tuple_base<
1154        tuple<A, B, C, D, E, F, G, H, I, J, K, L, M> > {
1155
1156    BOOST_STATIC_CONSTANT(int, length = 13);
1157    typedef A a_type; typedef B b_type;
1158    typedef C c_type; typedef D d_type;
1159    typedef E e_type; typedef F f_type;
1160    typedef G g_type; typedef H h_type;
1161    typedef I i_type; typedef J j_type;
1162    typedef K k_type; typedef L l_type;
1163    typedef M m_type;
1164
1165    tuple() {}
1166
1167    tuple(
1168        typename call_traits<A>::param_type a_,
1169        typename call_traits<B>::param_type b_,
1170        typename call_traits<C>::param_type c_,
1171        typename call_traits<D>::param_type d_,
1172        typename call_traits<E>::param_type e_,
1173        typename call_traits<F>::param_type f_,
1174        typename call_traits<G>::param_type g_,
1175        typename call_traits<H>::param_type h_,
1176        typename call_traits<I>::param_type i_,
1177        typename call_traits<J>::param_type j_,
1178        typename call_traits<K>::param_type k_,
1179        typename call_traits<L>::param_type l_,
1180        typename call_traits<M>::param_type m_
1181    ):  a(a_), b(b_), c(c_), d(d_), e(e_),
1182        f(f_), g(g_), h(h_), i(i_), j(j_),
1183        k(k_), l(l_), m(m_) {}
1184
1185    template <typename TupleT>
1186    tuple(TupleT const& init)
1187    :   a(init[tuple_index<0>()]), b(init[tuple_index<1>()]),
1188        c(init[tuple_index<2>()]), d(init[tuple_index<3>()]),
1189        e(init[tuple_index<4>()]), f(init[tuple_index<5>()]),
1190        g(init[tuple_index<6>()]), h(init[tuple_index<7>()]),
1191        i(init[tuple_index<8>()]), j(init[tuple_index<9>()]),
1192        k(init[tuple_index<10>()]), l(init[tuple_index<11>()]),
1193        m(init[tuple_index<12>()])
1194    { BOOST_STATIC_ASSERT(TupleT::length == length); }
1195
1196    A a; B b; C c; D d; E e;
1197    F f; G g; H h; I i; J j;
1198    K k; L l; M m;
1199};
1200
1201///////////////////////////////////////////////////////////////////////////////
1202//
1203//  tuple <14 member> class
1204//
1205///////////////////////////////////////////////////////////////////////////////
1206template <
1207    typename A, typename B, typename C, typename D, typename E,
1208    typename F, typename G, typename H, typename I, typename J,
1209    typename K, typename L, typename M, typename N>
1210struct tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, nil_t, nil_t>
1211:   public tuple_base<
1212        tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N> > {
1213
1214    BOOST_STATIC_CONSTANT(int, length = 14);
1215    typedef A a_type; typedef B b_type;
1216    typedef C c_type; typedef D d_type;
1217    typedef E e_type; typedef F f_type;
1218    typedef G g_type; typedef H h_type;
1219    typedef I i_type; typedef J j_type;
1220    typedef K k_type; typedef L l_type;
1221    typedef M m_type; typedef N n_type;
1222
1223    tuple() {}
1224
1225    tuple(
1226        typename call_traits<A>::param_type a_,
1227        typename call_traits<B>::param_type b_,
1228        typename call_traits<C>::param_type c_,
1229        typename call_traits<D>::param_type d_,
1230        typename call_traits<E>::param_type e_,
1231        typename call_traits<F>::param_type f_,
1232        typename call_traits<G>::param_type g_,
1233        typename call_traits<H>::param_type h_,
1234        typename call_traits<I>::param_type i_,
1235        typename call_traits<J>::param_type j_,
1236        typename call_traits<K>::param_type k_,
1237        typename call_traits<L>::param_type l_,
1238        typename call_traits<M>::param_type m_,
1239        typename call_traits<N>::param_type n_
1240    ):  a(a_), b(b_), c(c_), d(d_), e(e_),
1241        f(f_), g(g_), h(h_), i(i_), j(j_),
1242        k(k_), l(l_), m(m_), n(n_) {}
1243
1244    template <typename TupleT>
1245    tuple(TupleT const& init)
1246    :   a(init[tuple_index<0>()]), b(init[tuple_index<1>()]),
1247        c(init[tuple_index<2>()]), d(init[tuple_index<3>()]),
1248        e(init[tuple_index<4>()]), f(init[tuple_index<5>()]),
1249        g(init[tuple_index<6>()]), h(init[tuple_index<7>()]),
1250        i(init[tuple_index<8>()]), j(init[tuple_index<9>()]),
1251        k(init[tuple_index<10>()]), l(init[tuple_index<11>()]),
1252        m(init[tuple_index<12>()]), n(init[tuple_index<13>()])
1253    { BOOST_STATIC_ASSERT(TupleT::length == length); }
1254
1255    A a; B b; C c; D d; E e;
1256    F f; G g; H h; I i; J j;
1257    K k; L l; M m; N n;
1258};
1259
1260///////////////////////////////////////////////////////////////////////////////
1261//
1262//  tuple <15 member> class
1263//
1264///////////////////////////////////////////////////////////////////////////////
1265template <
1266    typename A, typename B, typename C, typename D, typename E,
1267    typename F, typename G, typename H, typename I, typename J,
1268    typename K, typename L, typename M, typename N, typename O>
1269struct tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, nil_t>
1270:   public tuple_base<
1271        tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O> > {
1272
1273    BOOST_STATIC_CONSTANT(int, length = 15);
1274    typedef A a_type; typedef B b_type;
1275    typedef C c_type; typedef D d_type;
1276    typedef E e_type; typedef F f_type;
1277    typedef G g_type; typedef H h_type;
1278    typedef I i_type; typedef J j_type;
1279    typedef K k_type; typedef L l_type;
1280    typedef M m_type; typedef N n_type;
1281    typedef O o_type;
1282
1283    tuple() {}
1284
1285    tuple(
1286        typename call_traits<A>::param_type a_,
1287        typename call_traits<B>::param_type b_,
1288        typename call_traits<C>::param_type c_,
1289        typename call_traits<D>::param_type d_,
1290        typename call_traits<E>::param_type e_,
1291        typename call_traits<F>::param_type f_,
1292        typename call_traits<G>::param_type g_,
1293        typename call_traits<H>::param_type h_,
1294        typename call_traits<I>::param_type i_,
1295        typename call_traits<J>::param_type j_,
1296        typename call_traits<K>::param_type k_,
1297        typename call_traits<L>::param_type l_,
1298        typename call_traits<M>::param_type m_,
1299        typename call_traits<N>::param_type n_,
1300        typename call_traits<O>::param_type o_
1301    ):  a(a_), b(b_), c(c_), d(d_), e(e_),
1302        f(f_), g(g_), h(h_), i(i_), j(j_),
1303        k(k_), l(l_), m(m_), n(n_), o(o_) {}
1304
1305    template <typename TupleT>
1306    tuple(TupleT const& init)
1307    :   a(init[tuple_index<0>()]), b(init[tuple_index<1>()]),
1308        c(init[tuple_index<2>()]), d(init[tuple_index<3>()]),
1309        e(init[tuple_index<4>()]), f(init[tuple_index<5>()]),
1310        g(init[tuple_index<6>()]), h(init[tuple_index<7>()]),
1311        i(init[tuple_index<8>()]), j(init[tuple_index<9>()]),
1312        k(init[tuple_index<10>()]), l(init[tuple_index<11>()]),
1313        m(init[tuple_index<12>()]), n(init[tuple_index<13>()]),
1314        o(init[tuple_index<14>()])
1315    { BOOST_STATIC_ASSERT(TupleT::length == length); }
1316
1317    A a; B b; C c; D d; E e;
1318    F f; G g; H h; I i; J j;
1319    K k; L l; M m; N n; O o;
1320};
1321
1322#endif
1323#endif
1324#endif
1325#endif
1326
1327///////////////////////////////////////////////////////////////////////////////
1328}   //  namespace phoenix
1329
1330#endif
Note: See TracBrowser for help on using the repository browser.