On Tue, Jul 12, 2016 at 06:37:35AM +0000, Mike Parker via Digitalmars-d-learn wrote: > On Tuesday, 12 July 2016 at 03:57:09 UTC, Bahman Movaqar wrote: > > What should be signature of `foo` in the following piece of code? > > > > auto foo(range r) { > > // do something with the `r` > > } > > > > void main() { > > foo([1,2,3].map!(x => x*x)); > > } > > > > > > auto foo(R)(R r) { ... }
Better yet: import std.range.primitives; auto foo(R)(R r) if (isInputRange!R) { ... } This is to ensure R is actually a range, so that, for example, foo(123) will be rejected at compile-time. T -- "A man's wife has more power over him than the state has." -- Ralph Emerson