[1.33][tuple] Problem with tuples longer than 10 elements

Hi The code: #include <boost/tuple/tuple.hpp> typedef boost::tuple<int,double,char,int,double,double,double,double,double,double> Foo; int main() {} Is working. But if I add one more field: #include <boost/tuple/tuple.hpp> typedef boost::tuple<int,double,char,int,double,double,double,double,double,double,double> Foo; int main() {} I have an error: tuple_type.cpp:3: error: wrong number of template arguments (11, should be 10) /usr/include/boost/tuple/detail/tuple_basic.hpp:75: error: provided for ?template<class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9> class boost::tuples::tuple? tuple_type.cpp:3: error: invalid type in declaration before ?;? token Why this error occurs? My kompiler is gcc 4.1 Regards. -- |\/\/| Seweryn Habdank-Wojewódzki \/\/

That is general limitation. The documentation says: "The current version supports tuples with 0-10 elements." If you want more and more features I would recommend using boost::fusion. This is an awesome lib. But your compiler will hate it. ;-) Let me know if you have more questions. Christian On 5/15/07, Seweryn Habdank-Wojewódzki <shw@agh.edu.pl> wrote:
Hi
The code:
#include <boost/tuple/tuple.hpp>
typedef boost::tuple<int,double,char,int,double,double,double,double,double,double> Foo;
int main() {}
Is working. But if I add one more field:
#include <boost/tuple/tuple.hpp>
typedef boost::tuple<int,double,char,int,double,double,double,double,double,double,double> Foo;
int main() {}
I have an error:
tuple_type.cpp:3: error: wrong number of template arguments (11, should be 10) /usr/include/boost/tuple/detail/tuple_basic.hpp:75: error: provided for ?template<class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9> class boost::tuples::tuple? tuple_type.cpp:3: error: invalid type in declaration before ?;? token
Why this error occurs?
My kompiler is gcc 4.1
Regards.
--
|\/\/| Seweryn Habdank-Wojewódzki \/\/ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi
That is general limitation. The documentation says:
"The current version supports tuples with 0-10 elements."
OK. I did not find that.
If you want more and more features I would recommend using boost::fusion. This is an awesome lib. But your compiler will hate it. ;-)
I will look. :-)
Let me know if you have more questions.
Thanks a lot, for information. Best regards. -- |\/\/| Seweryn Habdank-Wojewódzki \/\/

----- Mensaje original ----- De: Seweryn Habdank-Wojewódzki <shw@agh.edu.pl> Fecha: Martes, Mayo 15, 2007 11:48 pm Asunto: Re: [Boost-users] [1.33][tuple] Problem with tuples longer than 10 elements Para: boost-users@lists.boost.org
Hi
That is general limitation. The documentation says:
"The current version supports tuples with 0-10 elements."
OK. I did not find that.
If you don't mind using a more cumbersome notation, cons lists can be used to circumvent this limitation: http://boost.org/libs/tuple/doc/tuple_advanced_interface.html For instance: #include <boost/tuple/tuple.hpp> struct T0{}; struct T1{}; struct T2{}; struct T3{}; struct T4{}; struct T5{}; struct T6{}; struct T7{}; struct T8{}; struct T9{}; struct T10{}; struct T11{}; struct T12{}; struct T13{}; struct T14{}; struct T15{}; typedef boost::tuples::cons<T0, boost::tuples::cons<T1, boost::tuples::cons<T2, boost::tuples::cons<T3, boost::tuples::cons<T4, boost::tuples::cons<T5, boost::tuples::cons<T6, boost::tuples::cons<T7, boost::tuples::cons<T8, boost::tuples::cons<T9, boost::tuples::cons<T10, boost::tuples::cons<T11, boost::tuples::cons<T12, boost::tuples::cons<T13, boost::tuples::cons<T14, boost::tuples::cons<T15,boost::tuples::null_type
> > > > > > > > > > long_tuple;
int main() { long_tuple lt; T10 t10=lt.get<10>(); } HTH, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Hi!
If you don't mind using a more cumbersome notation, cons lists can be used to circumvent this limitation:
http://boost.org/libs/tuple/doc/tuple_advanced_interface.html
For instance:
#include <boost/tuple/tuple.hpp>
[...]
int main() { long_tuple lt; T10 t10=lt.get<10>(); }
What I could say? It's really cool :-). By the way it was my fault that I do not find "10 elements boundary". I have just opened the book about boost (by Karlsson) and there is written about this limitation on the second page about tuples. I am sorry for the mess. Regards. -- |\/\/| Seweryn Habdank-Wojewódzki \/\/

On 5/15/07, Seweryn Habdank-Wojewódzki <shw@agh.edu.pl> wrote:
By the way it was my fault that I do not find "10 elements boundary". I have just opened the book about boost (by Karlsson) and there is written about this limitation on the second page about tuples.
Just curious, did the book mention the cons solution? Tony

I suspect you mean the Beyond the C++ Standard Library book. I don't think it's mentioned there. It's not in the index and by browsing through the tuple's chapter I could make out references to cons. Christian On 5/17/07, Gottlob Frege <gottlobfrege@gmail.com> wrote:
On 5/15/07, Seweryn Habdank-Wojewódzki <shw@agh.edu.pl> wrote:
By the way it was my fault that I do not find "10 elements boundary". I have just opened the book about boost (by Karlsson) and there is written about this limitation on the second page about tuples.
Just curious, did the book mention the cons solution?
Tony _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi Gottlob Frege wrote:
On 5/15/07, Seweryn Habdank-Wojewódzki <shw@agh.edu.pl> wrote:
By the way it was my fault that I do not find "10 elements boundary". I have just opened the book about boost (by Karlsson) and there is written about this limitation on the second page about tuples.
Just curious, did the book mention the cons solution?
No. The book says, that for advance topics look to the website. However for example iteration on tuples are explained. What is in my opinion more tricky then "cons" stuff. Regards. -- |\/\/| Seweryn Habdank-Wojewódzki \/\/
participants (4)
-
"JOAQUIN LOPEZ MU?Z"
-
Christian Henning
-
Gottlob Frege
-
Seweryn Habdank-Wojewódzki