Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2002-02-18 11:36:14

Peter Dimov wrote:
> From: "Daniel Frey" <daniel.frey_at_[hidden]>
> >>>
> I'm reading all those pro-'auto' comments with a little fear. Why it
> 'auto' really needed if we have a good typeof? Example:
> <<<
> It depends on what you consider a 'good' typeof. A typeof that makes it easy
> to do auto/let things (IOW one that strips references and top-level cv
> qualifiers) isn't a good typeof as far as I'm concerned because it has
> little value.


> There's also the fact that when you have to repeat a complex expression
> twice you will make an error sooner or later. :-)

IMHO the question is: If we have your typeof, can we write a class
'auto' that doesn't require any further language support? Or something
which is similar, easy and doesn't "pollute" the language? Currently, a
function can deduct the template parameters from it's arguments. Can a
constructor do the same? Should it? Consider:

template< typename T > class auto // or 'any'
   typedef ::boost::remove_reference< ::boost::remove_cv< T >::type
>::type type;

   type content;

   auto( T arg ) : content( arg ) {}
   operator T { return content; }

OK, the code is bad, but I hope you get the idea... basically, it should
be usable as

auto v( func< T, U, V >() );

but without 'auto' being a keyword that makes the compiler more complex.
The question is, if the language supports 'auto' instead of 'auto<...>'
like function calls today...

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