Pass enum variable as const ref arg

rikki cattermole rikki at cattermole.co.nz
Fri Dec 4 12:57:04 UTC 2020


On 05/12/2020 1:54 AM, Andrey wrote:
> Hello,
> 
>> void test(const ref string[3] qazzz) { qazzz.writeln; }
>>
>> void main()
>> {
>>     enum string[3] value = ["qwer", "ggg", "v"];

That is a compile time constant (remove the enum).

>>     test(value);
>> }
> 
> Gives errors:
> 
>> onlineapp.d(26): Error: function onlineapp.test(ref const(string[3]) 
>> qazzz) is not callable using argument types (string[3])
>> onlineapp.d(26):        cannot pass rvalue argument ["qwer", "ggg", 
>> "v"] of type string[3] to parameter ref const(string[3]) qazzz
> 
> WTF?

The ref. The problem is the ref. You are passing it a constant, not a 
variable.


More information about the Digitalmars-d-learn mailing list