On Wednesday, 9 September 2015 at 07:19:06 UTC, Bahman Movaqar wrote:
On Tuesday, 8 September 2015 at 18:45:33 UTC, Jonathan M Davis wrote:
If you're returning a range, you should be returning auto.

@Jonathan, @cym13 and @Meta
It's reasonable to use `auto`. However there are times when you need to pass the `auto` value to another function and the receiving function needs to know the type of its input arguments.

No, it doesn't. It needs to know what the compile-time interface is, i.e. what it can do with that type. If the type in question happens to be an InputRange, then the consumer function would be:

void func(R)(R range) if(isInputRange!R) { ... }

instead of using a concrete type like this:

void func(MyType range) { ... }

That way you can change range types and `func` doesn't care.

Atila

Reply via email to