This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [libstdc++] Doxygen markup for algorithms


--- Jonathan Wakely <cow@compsoc.man.ac.uk> wrote:
> I was
> working mainly from
> the SGI docs when I started, and should have gone
> back to review it with
> the other sources I was using (Josutis isn't one of
> them unfortunately)
FWIW I find Austern's book the best reference for this
stuff, it even documents the sgi extensions.
 
> Reading the text of the proposal am I right in
> thinking it can modify the
> argument so long as it doesn't change anything that
> would affect the
> ordering of the sequence?
That's basicly what I get out of it. So something
like:

struct Bad_Func
{
 Bad_Func( std::set<int>& whole_set_ ) : whole_set(
while_set_ ){}
 void operator()( int element ) const
 {
  whole_set.erase( element );
 }
 std::set<int>& while_set;
};

{
 std::set<int> local_set( .... );
 std::for_each(
  local_set.begin(),
  local_set.end(),
  Bad_Func( local_set ));
}

Would have undefined results.

> To be honest, I'm glad the function object can
> modify its arg, as I've
> got code that uses a functor to delete each pointer
> in a sequence, so now
> I know it's standard conforming  :)
Item 7 in Meyers' Effective STL does exactly this.
 
> Thanks for spotting it!
Thanks for writing doc!

-Kenny

__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]