|
Boost Users : |
From: Jaakko Jarvi (jajarvi_at_[hidden])
Date: 2002-09-03 12:10:35
> Thanks for replying. It works if the constructor is written
> cons() {}
>
> Is there any purpose to putting those default calls there?
Took a while to reply, but yes, there is a reason behind this.
With
cons() : head(), tail() {}
the elements get default initialized, whitout the default calls they
don't. And some compiler emit warnings if they are missing.
And std::pair has those.
Cheers, Jaakko
Also, without the explicit initializers, one couldn't declare tuples
with const element types. Say const<>
> Tom
>
> > From: Jaakko Jarvi [mailto:jajarvi_at_[hidden]]
> > Sent: Thursday, August 29, 2002 8:16 AM
> >
> > Hi Tom,
> >
> > Your code compiles fine with gcc 3.x and icc 6 (linux), so it may just
> > be gcc 2.96 problem.
> >
> > Cheers, Jaakko
> >
> > On Wed, 28 Aug 2002, Tom Matelich wrote:
> >
> > > It appears that an enum cannot be default constructed in
> > the way that
> > > tuple
> > > does,
> > > cons() : head(), tail() {}
> > >
> > > Any idea on how to get around this (besides using an int in
> > the tuple)?
> > >
> > > Thanks,
> > > Tom
> > >
> > >
> > > <sample_code>
> > >
> > > #include <boost/tuple/tuple.hpp>
> > > #include <string>
> > >
> > > enum Foo { Willis, Arnold };
> > >
> > > void test()
> > > {
> > > boost::tuple<Foo, std::string> a;
> > > }
> > >
> > > </sample_code>
> > >
> > > </error compiler="gcc version 2.96 20000731 (Mandrake Linux 8.2)">
> > >
> > >
> > /usr/local/eddynet/opt/include/boost/tuple/detail/tuple_basic.hpp: In
> > > method
> > > `boost::tuples::cons<HT,
> > > TT>::cons () [with HT = Foo, TT = boost::tuples::cons<string,
> > > boost::tuples::null_type>]':
> > >
> > /usr/local/eddynet/opt/include/boost/tuple/detail/tuple_basic.hpp:454:
> > > instantiated from `boost::tuples::tuple<T0, T1, T2, T3, T4,
> > T5, T6, T7,
> > > T8,
> > > T9>::tuple () [with T0 = Foo, T1 = string, T2 =
> > > boost::tuples::null_type, T3
> > > = boost::tuples::null_type, T4 = boost::tuples::null_type, T5 =
> > > boost::tuples::null_type, T6 = boost::tuples::null_type, T7 =
> > > boost::tuples::null_type, T8 = boost::tuples::null_type, T9 =
> > > boost::tuples::null_type]'
> > > tuple_enum_test.cpp:8: instantiated from here
> > >
> > /usr/local/eddynet/opt/include/boost/tuple/detail/tuple_basic.hpp:263:
> > > cannot convert `int' to `Foo' in
> > > assignment
> > >
> > > </error>
> > >
> > >
> > >
> > --------------------------------------------------------------
> > ---------
> > > DISCLAIMER: Information contained in this message and/or
> > > attachment(s) may contain confidential information of Zetec, Inc.
> > > If you have received this transmission in error, please notify
> > > the sender by return email.
> > >
> > --------------------------------------------------------------
> > ---------
> > >
> > > Yahoo! Groups Sponsor
> > > ADVERTISEMENT
> > >
> > > Info: <http://www.boost.org>
> > > Wiki:
> <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
> > Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
> >
> >
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> >
>
> --
> --
> -- Jaakko Järvi email: jajarvi_at_[hidden]
> -- Post Doctoral Fellow phone: +1 (812) 855-3608
> -- Pervasive Technology Labs fax: +1 (812) 855-4829
> -- Indiana University, Bloomington
>
>
>
>
> Info: <http://www.boost.org>
> Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
> Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
> Yahoo! Groups Sponsor
> ADVERTISEMENT
>
> Info: <http://www.boost.org>
> Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
> Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
>
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
-- -- -- Jaakko Järvi email: jajarvi_at_[hidden] -- Post Doctoral Fellow phone: +1 (812) 855-3608 -- Pervasive Technology Labs fax: +1 (812) 855-4829 -- Indiana University, Bloomington
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net