opIndex operators

Jesse Phillips Jessekphillips+d at gmail.com
Sun Apr 14 12:15:56 PDT 2013


On Sunday, 14 April 2013 at 06:57:34 UTC, gedaiu wrote:
> Error: function base.Value.Value.opIndex (Value index) is not 
> callable using argument types (string)
> Error: cannot implicitly convert expression ("string") of type 
> string to Value
>
> I have implemented this methods:
> this(string)
> Value opCast(string val)
> Value opAssign(ref const string val)

void foo(Value v);

foo("my value?");

This code does not compile unless Value is defined as

alias Value = string;

You'd call it:

foo(Value("my value"));



More information about the Digitalmars-d-learn mailing list