Saturday 15 March 2014

c++ - why auto cannot be used to overload functions? -


I understand that use of template is a commendable way of overloading but I'm thinking Why was the code to be used for type parameter type> Auto can not be used, so the overloading of the function is being done?

In N3690 7.6.1.4/3, that the Lambda expression can be made by providing this example, generic using Auto,

 < Code> auto gladda = [] (int i, auto a) {return i; }; // OK: A generic lambda   

(Note: this is not mentioned in N3485)

1). Why not I have a general eg.

  Function for zero swap (Auto and Parma 1, Delft (Ultimate 1) and Ultimate 2) {decltype (param1) temp = param1; Param1 = param2; Param2 = temp; }   

this error returns error: the parameter declared Auto .

N3690 7.1.6.4/4

The type of variable declared by auto or delftype (auto) is less than its initiality. This usage is allowed in the namespace area (3.3.6) and in a for-init-statement (6.5.3) while declaring a variable in one block (6.3) . [...]

Do I believe that the param1 and param2 fall into the scope of the block and therefore for auto deduction Are you eligible?

2). What would be the harm if such facility was allowed?

I am using GCC 4.8.1.

Thanks

n3690 7.1.6.4/2

The type of placeholder in any reference in any reference, where an announcer is valid, declaration of function declaration in declaration-specifier-seq, type-specifier-seq, conversion-function-id, or trailing-return-type May appear along. 7.1.6.4/3

If a type-specificifier declares one of the declaration-declaration-declaration-declaration-declaration-declaration of a parameter in the declaration of one of the declarations Appears in Lambda is a generic lambda. 7.1.6.4/4

The type of variable declared by automated or deprecated (auto) has been reduced to its initial. The use of variables in blocks (6.3) in the scope of names (3.3.6) and in a for-init-statement (6.5.3), is less used. Auto or Delftip (Auto) will appear in Deed-Excerpt-CEC as a Develop-Specifier, and DeD-Specier-CEC will run with one or more Init-Delighters, each of which will be a blank initial - Iizer. 7.1.6.4/5

The type of a placeholder can also be used to declare a variable in the case of a selection statement (6.4) Or type-id in a new-expression (5.3.4), in a range-declaration, and in a steady declaration, a recurrence statement (6.5) data member who defines a class (9.4. 2) appears within the member-specifications, with the brace-or-equal-initiator. Only such use is cautious. Any other use is prohibited (especially in use in parameter-declaration-clause )

7.1.6.4/6

This section explicitly permits In any given reference, any program using auto or delta type (auto) in the context has become ill.

No comments:

Post a Comment