Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2002-02-19 04:19:20

Herb Sutter wrote:
> > Or how about allowing
> >
> > std::vector< ...complex sub-types, ... > v;
> > for( v::const_iterator it = v.begin(); it != v.end() ++it)
> Wouldn't the "auto" proposal (almost) do that?
> for( auto it = v.begin(); it != v.end(); ++it )

Certainly it would, but the origin of this thread was to find out
whether 'auto' is needed at all. It seems that everybody (including
myself) agrees that typeof() is a good idea and I think that the version
returning 'const T&' instead of 'T' (see Peter Dimov's message) is
reasonable. Now, if we have typeof(), what other, small but most general
enhancements would be necessary to allow writing a class 'auto' with the
requested behaviour? I'm not yet convinced that 'auto' as a
language-feature gives us the most possible power in the future.

> In this case it becomes an iterator, not a const_iterator, though. Is that a
> big deal, or is "auto" alone sufficient to cover most of the desired
> functionality?

You already mention one drawback. Why not think of a better solution? It
is just me feeling that there *is* a better solution? I don't like to
give up so soon and accept 'auto' as a keyword. For the example above,

   for( typeof( v )::const_iterator it = v.begin(); it != v.end(); ++it

or, as Wilka suggested 'v::const_iterator', has more power and is still
a good improvement over the current situation. Especially the people at
boost have shown what is possible to do with a minimalistic language and
the right ideas.

Regards, Daniel

Daniel Frey
aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web:

Boost list run by bdawes at, gregod at, cpdaniel at, john at