auto ref and non-templated functions

Robert Clipsham robert at octarineparrot.com
Mon Dec 24 11:43:06 PST 2012


On Monday, 24 December 2012 at 17:40:54 UTC, Jonathan M Davis 
wrote:
> This has probably been discussed before, so someone has 
> probably already
> explained why this is a bad idea, but I can't remember why that 
> would be, so
> I'm going to ask:
>
> Why can't we simply make auto ref work with non-templated 
> functions by making
> it automatically generate both the ref and non-ref versions? 
> So, if I do
>
> auto foo(auto ref S s) { /*do stuff*/ }

Is:

auto foo()(auto ref S e) { /* do stuff */ }

So hard to write?

(It's Christmas Eve, and I can't be bothered giving real 
arguments against right now - I suppose someone else will do this 
later... Merry Christmas!)

Robert



More information about the Digitalmars-d mailing list