Returning a reference to be manipulated
Dennis
dkorpel at gmail.com
Sat Apr 15 15:50:18 UTC 2023
On Saturday, 15 April 2023 at 14:33:52 UTC, kdevel wrote:
> Does that make sense?
Whether it makes sense is subjective, but it is by design. Escape
analysis considers every pointer the same, it doesn't care about
the type / mutability of the pointer. In `@system` / `@trusted`
code, you could coerce `i` to become a string and return it:
```D
string foo(string s, return ref int i)
{
return (cast(immutable char*) &i)[0..4];
}
```
More information about the Digitalmars-d-learn
mailing list