On Friday, 23 June 2017 10:01:01 PDT
teco...@gmail.com wrote:
> I expected to use auto statement to function parameters as shown below:
>
> warning: ISO C++ forbids use of ‘auto’ in parameter declaration [-Wpedantic
> ]|
>
> > auto function(auto Var) {
> > (...)
> > }
>
> This flexibility is important in my opinion.
You're getting the warning because the above is not part of C++14. It is part
of the Concepts TS, though. So if you compile with
-std=c++1z -fconcepts
You'll get no warning.
> Furthermore, if it is really
> approved, this kind of statement may substitute, at least in part, the
> verbose, not elegant and not so clear template statement as shown below?
>
> template <typename T>T function(T Var){
>
> > (...)}
>
> If it can't, i think it could be proposed.
It's already proposed and it does not mean what you wrote. It means, instead:
template <typename T> auto function(T var)
{
....
}
The important difference is what Jens said: the return type is not necessarily
the same as the parameter type.
--
Thiago Macieira - thiago (AT)
macieira.info - thiago (AT)
kde.org
Software Architect - Intel Open Source Technology Center