https://issues.dlang.org/show_bug.cgi?id=9983

Steven Schveighoffer <schvei...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schvei...@yahoo.com

--- Comment #2 from Steven Schveighoffer <schvei...@yahoo.com> ---
I actually went over this in my inout talk a few years ago.

a couple of points here:

1. The OP's request is invalid. There is no way for f to know what the
mutability qualifier is, as inout is not a template parameter, it's a
qualifier.

2. inout members should be allowed inside structs, they will work just fine. I
wish they hadn't been disallowed.

The only thing you wouldn't be able to do is call a function that returns a
struct with inout members with a different mutability qualifier than inout.

e.g. this should work:

inout int[] x;
auto foo = f(x); // OK, returns Foo!(inout(int))

But this shouldn't:

int[] x;
auto foo = f(x); // Error, cannot convert struct with inout members to proper
mutability.

There is no way for the compiler to know that it could potentially convert the
return value to mutable T, even when it knows that Foo is a template.

We should either close this bug as invalid, or repurpose to request support for
structs with inout members.

--

Reply via email to