On 2010-03-20 07:53:34 -0400, Michel Fortin <[email protected]> said:

        struct WrapperRange(R) {
                R wrappedRange;
                void applyFront(void delegate(ref ElementType!R) actor) {
                        actor(wrappedRange.front);
                }
        }

        R range;
        // Instead of this:
        range.front.callSomeFunc();
        // Use this:
        range.applyFront!((ref ElementType!R e) { e.callSomeFunc(); })();

Hum, this last line doesn't work, I should have written this:

        range.applyFront((ref ElementType!R e) { e.callSomeFunc(); });

No template. It could be done with a template, but then it couldn't work for virtual functions.

--
Michel Fortin
[email protected]
http://michelf.com/

Reply via email to