This is a GCC error.
auto not allowed in function parameter declarations in C ++ 14. This syntax is added by Concepts Lite TS. GCC 4.9 release notes say
g ++ supports the unlimited common functions specified in Β§ 4.1.1.2 and Β§5.1.1 of N3889: Basic Lite. In short, auto can be used as a type specifier in a parameter declaration of any function of a declarator to introduce a template for an implicit function parameter similar to common lambdas.
N3889 is an early working draft of TS concepts. The above section, 5.1.1, is partially read.
A common function is indicated by the declarator of the auto function or the name of the concept as part of the type specifier in its Parameter declaration of the subordinate clause. [Example:
auto f(auto x);
- end of example]
The use of auto or a conceptual name in a parameter-declaration-sentence is interpreted as the use of a parameter of a type having the same restrictions and a named concept. [Note. The exact mechanism to achieve this is unspecified. - end note] [Example: general function declared below
auto f(auto x, const Regular& y);
Equivalent to next ad
template<typename T1, Regular T2> auto f(T1 x, const T2&);
- end of example]
Note that this conversion should not affect the return type; it remains auto - this means that it will be displayed.
Given these rules, an autofunc should be equivalent
template<class T> decltype(auto) autofunc( const T& a) { }
which would be valid. Instead, he received an interpretation as
template<class T> T autofunc( const T& a) { }
causes an error, because when performing the entire T transfer, the output ends as an array type.
This is ironic, as GCC 4.9's own notes (cited above) say that
// the following two function declarations are equivalent auto incr(auto x) { return x++; } template <typename T> auto incr(T x) { return x++; }
which is clearly not the case on GCC 4.9.