foreach for ranges?
Jonathan M Davis
jmdavisProg at gmx.com
Tue Jul 17 22:46:11 PDT 2012
On Wednesday, July 18, 2012 07:19:59 Kapps wrote:
> If UFCS worked on operators, you would be able to make ranges
> without any compiler support.
>
> int opApply(T)(T Range) if(isInputRange!T) {
> // Stuff.
> }
You can't overload operators externally to a user-defined type. They must be
part of the user-defined type that they operate on.
Also, UFCS makes no sense on overloaded operators, because they don't get
called with ".", and all UFCS is is changing obj.func(params) to func(obj,
params).
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list