[Issue 620] Can't use property syntax with a template function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 1 22:24:55 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=620


Alex Khmara <alex.khmara at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alex.khmara at gmail.com


--- Comment #4 from Alex Khmara <alex.khmara at gmail.com> 2011-01-01 22:22:42 PST ---
(In reply to comment #3)
> Some hacking about showed me that opDispatch has a workaround for this problem,
> by using a two-layer approach:
> 
> template opDispatch( string name ) {
>     auto opDispatch( T... )( T args ) {
>         // Do something!
>     }
> }

This workaroung is only partial. This code produces "Error: s.opDispatch(T...)
has no value".

import std.stdio;

struct S {
    template opDispatch( string name ) {
        string opDispatch( T... )( T args ) {
            return "bar";
        }
    }
}

void main() {
    S s;
    string str = s.foo;
}

Same if I try "auto opDispatch" instead of "string".

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list