Automatic parameter type in functions

I would like to know if the standard committee considered expanding the C ++ 14 keyword autoto deduce the type of the function template parameter, as it exists today in common lambdas. ( as one could beautifully portray in this answer )

Since it works in lambda functions, it should also work in any function. Of course, this would be completely redundant with the classic syntax:

template< typename T >
void f(T param);

But having the opportunity to write this, for the same result:

void f(auto param);

I think this will allow for less clogged code (a shorter cleaner) and more consistency in this case:

auto v = func1();
f(v);

, auto type v, f, templated f.
auto auto, .

: , . , user657267, .

+4
1

, , , , , , :

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4040.pdf

. 16, 5.1.1 generic functions

- , template-parameter-list , - , .

[:

auto f(auto x); // Ok
void sort(C& c); // Ok (assuming C names a concept)

- ]

:)

, :

- .

[: :

template<typenaem T>  
conxtexpr bool C() { ... }  
auto f(auto x, const C& y);  
template<typename T1, C T2> 
auto f(T1 x, const T2& y);

y - , C. - end]

+4

Source: https://habr.com/ru/post/1599837/


All Articles