Pete Bartlett | 1 Jul 01:41

[foreach][range] How would BOOST_REVERSE_FOREACH be implemented?

Boost.Foreach is such a great piece of kit that once you start using it you just can’t stop. Indeed I like working directly with values rather than iterators so much that is feels normal for me to write something like

 

BOOST_FOREACH( value_type x , make_iterator_range( rbegin( seq ) , rend( seq ) )

 

whenever I wish to reverse iterate over a sequence. My co-workers are not big fans of typing though, so they want a REVERSE_FOREACH. At first naïve glance it looks easy to implement in terms of the original FOREACH:

 

template<typename C> inline iterator_range</* something */> make_reverse_iterator_range(C& c)

{

            return make_iterator_range( rbegin(c) , rend(c) );

}

#define REVERSE_FOREACH( x , container ) BOOST_FOREACH( x , make_reverse_iterator_range( container ) )

 

This works fine when container is an lvalue. But then co-workers, used to the wonders of the original FOREACH, inevitably start to use the new macro with rvalues and get a crash due to dangling references (– the iterator_range’s members point to departed quantities…..) and if you could somehow work around that, there is the issue hidden inside the “/* something */” that you have to cope with fact that MSVC has no proper const rvalue detection. Finally the

 

#define MACRO(x,y) ANOTHER_MACRO( f(x) , g(y) )

 

style is not recommended because they are brittle in the face of x and/or y themselves being macros.

 

… but all these issues are exactly the ones that BOOST_FOREACH itself solves! Thus surely it is technically possible to write a REVERSE_FOREACH that works with rvalues as well as lvalues, e.g. by essentially copying and pasting the FOREACH implementation and replacing “begin” and “end” by “rbegin” and “rend” in the vital places. However one feels there may be a better way… has anyone had a go at creating a “fully-functional” REVERSE_FOREACH and could offer me any advice? If indeed the task is fairly intricate and requires re-use of foreach internals, would the library author consider including something in the library itself?

 

Many thanks for reading,

Pete Bartlett

 

_______________________________________________
Boost-users mailing list
Boost-users <at> lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Marc Viala | 1 Jul 12:48

Re: [Boost.MathToolKit] Compilation problem w/ VC++7.1

> > Yes, I've tried to compile w/ the right header version of
> > math-toolkit.
> >
> > Just to be sure and to confirm the problem:
> >
> > Right now I'm using Boost 1.33.1. Do you confirm that math-toolkit
> > can operate only w/ Boost 1.34? If yes, sorry for the noise.
> 
> Yes, only 1.34, but I'd expect different error messages if you tried
to use
> with 1.33.1:
> 
> $ cl -GX -I../../ -I../../../../../1.33.1/boost_1_33_1 t.cpp
> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for
80x86
> Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
> 
> t.cpp
> ../../boost\math\tools\roots.hpp(13) : fatal error C1083: Cannot open
> include file: 'boost/tr1/tuple.hpp': No such file or directory

[Marc Viala] Amazing... I've just double checked my boost headers
directory and I confirm the use of 1.33.1. I didn't find any reference
of TR1 headers. 

> 
> > By the way, do you plan to adapt your headers for Boost 1.33.1?
> 
> Nope, too much to do, too little time, it'll become part of Boost 1.35
or
> 1.36 so there's no point in supporting earlier versions.

 [Marc Viala] OK. I'll look of your library when I'll do the boost
upgrade.

Thanks for your help & best regards

Marc Viala
Ewgenij Sokolovski | 1 Jul 14:06
Picon
Picon

Boost verion lookup

Hello. How can I find out which version of Boost is installed on my system? Currently I do it on the simple way
of opening the corresponding boost documentation installed with the boost library and looking at the
"latest news" entry. But it isn't a really proper way, is it? What is the right way then?:)

Ewgenij
--

-- 
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
Ewgenij Sokolovski | 1 Jul 14:40
Picon
Picon

Re: [Boost.Test] User Exception handling

> 2. use framework::setup_error to report initialization error
> 

Is it already in the 1.33.1 version? I couldn't find such a function.

> > And why it is not possible to determine the location of the exception
> (the 
> > line number) when I include it into myTestCase?
> 
> Because C++ doesn't provide a way ;). Do you know one?
> 

Nope:) But I'm not a C++-guru, I'm only a poor computer science student at the beginning of my professional career:)
--

-- 
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
Eric Niebler | 1 Jul 17:34
Picon
Favicon

Re: [foreach][range] How would BOOST_REVERSE_FOREACH be implemented?


Pete Bartlett wrote:
> #define REVERSE_FOREACH( x , container ) BOOST_FOREACH( x , 
> make_reverse_iterator_range( container ) )

Something like this is what I was going to suggest, but ...

> This works fine when container is an lvalue. But then co-workers, used 
> to the wonders of the original FOREACH, inevitably start to use the new 
> macro with rvalues and get a crash due to dangling references (– the 
> iterator_range’s members point to departed quantities…..)

... ouch. If the container is an rvalue, it will be copied by FOREACH, 
but it the "container" is really just a proxy (eg., an iterator pair) to 
a temporary object, then copying the proxy doesn't help you, as you've 
discovered.

<snip>

> … but all these issues are exactly the ones that BOOST_FOREACH itself 
> solves! Thus surely it is technically possible to write a 
> REVERSE_FOREACH that works with rvalues as well as lvalues, e.g. by 
> essentially copying and pasting the FOREACH implementation and replacing 
> “begin” and “end” by “rbegin” and “rend” in the vital places.

Yes.

  However
> one feels there may be a better way… has anyone had a go at creating a 
> “fully-functional” REVERSE_FOREACH and could offer me any advice? If 
> indeed the task is fairly intricate and requires re-use of foreach 
> internals, would the library author consider including something in the 
> library itself?

You're not the first to want a REVERSE_FOREACH, but this is the first 
legitimate argument I've heard for it. Could you go to 
http://svn.boost.org/trac and open a new ticket there. Make the ticket 
type "feature request" and the component "foreach". I'll look into it 
when I have a chance.

--

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com
Pete Bartlett | 1 Jul 19:22

Re: [foreach][range] How would BOOST_REVERSE_FOREACHbe implemented?


>You're not the first to want a REVERSE_FOREACH, but this is the first 
>legitimate argument I've heard for it. Could you go to 
>http://svn.boost.org/trac and open a new ticket there. Make the ticket 
>type "feature request" and the component "foreach". I'll look into it 
>when I have a chance.

Thanks very much for your interest, Eric.
I've set up a ticket on the issue which you can view at

http://svn.boost.org/trac/boost/ticket/1071

Pete Bartlett
Sohail Somani | 1 Jul 19:39

Re: Boost verion lookup

boost/version.hpp iirc.


-----Original Message-----
From: boost-users-bounces <at> lists.boost.org on behalf of Ewgenij Sokolovski
Sent: Sun 7/1/2007 5:06 AM
To: boost-users <at> lists.boost.org
Subject: [Boost-users] Boost verion lookup

Hello. How can I find out which version of Boost is installed on my system? Currently I do it on the simple way of opening the corresponding boost documentation installed with the boost library and looking at the "latest news" entry. But it isn't a really proper way, is it? What is the right way then?:)

Ewgenij
--
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
_______________________________________________
Boost-users mailing list
Boost-users <at> lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
Boost-users <at> lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
frederic.bron | 1 Jul 19:54

how to get the documentation of 1.34.0


Hello,

The documentation of 1.34.0 is on the www.boost.org web site. How can I download it? On sourceforge, I can
only find 1.33.1 and also I do not see any html package.
Is is possible to build it from the source package, how then?
Regards,

F. Bron

Avis :
Ce message et toute pièce jointe sont la propriété d'Alcan et sont destinés seulement aux personnes ou
à l'entité à qui le message est adressé. Si vous avez reçu ce message par erreur, veuillez le
détruire et en aviser l'expéditeur par courriel. Si vous n'êtes pas le destinataire du message, vous
n'êtes pas autorisé à utiliser, à copier ou à divulguer le contenu du message ou ses pièces jointes
en tout ou en partie.

Notice:
This message and any attachments are the property of Alcan and are intended solely for the named recipients
or entity to whom this message is addressed. If you have received this message in error
please inform the sender via e-mail and destroy the message. If you are not the intended recipient you are
not allowed to use, copy or disclose the contents or attachments in whole or in part.
John Maddock | 1 Jul 20:04
Picon

Re: how to get the documentation of 1.34.0

frederic.bron <at> alcan.com wrote:
> Hello,
>
> The documentation of 1.34.0 is on the www.boost.org web site. How can
> I download it? On sourceforge, I can only find 1.33.1 and also I do
> not see any html package.
> Is is possible to build it from the source package, how then?

Yes you can build it, but if you download the source then all the docs 
should just be there already, if not it's a bug in the packaging.

John. 
Jurko Gospodnetić | 1 Jul 19:06
Picon

[filesystem][Windows][1.34.0] Paths not getting normalized correctly.

   Hi.

   Boost.Filesystem's path::normalize() function does not remove the 
trailing '\\.' element and my guess is that it should.

   I'm using Boost 1.34.0 on Windows XP sp2 with MSVC 7.1.

   Some expected normalization examples:
     '.'            --> '.'
     '\\'           --> '\\'
     'aaa\\..'      --> '.'
     'aaa\\bbb\\..' --> 'aaa'
     'aaa'          --> 'aaa'

   Some unexpected  normalization examples:
     '\\.'              --> '\\.'     (expected '\\' )
     'aaa\\..\\.'       --> '.\\.'    (expected '.'  )
     'aaa\\..\\.\\.'    --> '.\\.'    (expected '.'  )
     'aaa\\..\\.\\.\\.' --> '.\\.'    (expected '.'  )
     'aaa\\bbb\\..\\.'  --> 'aaa\\.'  (expected 'aaa')
     'aaa\\.'           --> 'aaa\\.'  (expected 'aaa')

   Hope this helps...

   Best regards,
     Jurko Gospodnetić

_______________________________________________
Boost-users mailing list
Boost-users <at> lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Gmane