only parameters or stack-based variables can be `inout`

Bastiaan Veelo Bastiaan at Veelo.net
Mon Nov 25 14:24:44 UTC 2024


I suspect a bug in conv.to, am I right?

```d
import std;

enum E
{
     One,
     Two
}

// OK:
inout(int) fun(inout(int) i)
{
     writeln(i.to!string);
     return i;
}

// Fishy:
inout(E) gun(inout(E) e)
{
     //writeln(e.to!string); // only parameters or stack-based 
variables can be `inout`
     writeln((cast(Unqual!E)e).to!string); // OK
     return e;
}

void main()
{
     fun(1);
     gun(E.One);
}
```

-- Bastiaan


More information about the Digitalmars-d-learn mailing list