[Issue 12408] map does not like inout
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Mar 19 16:07:02 PDT 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12408
monarchdodra at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |monarchdodra at gmail.com
--- Comment #2 from monarchdodra at gmail.com 2014-03-19 16:06:56 PDT ---
Seems invalid to me. Take a look at this reduced example:
//----
struct L(T)
{
T t;
}
auto l(T)(T t)
{
return L!T();
}
class S
{
auto foo() inout
{
return l(a);
}
int a;
}
void main() { }
//----
What's basically happening in "foo", is you are creating a type
`L!(inout(int))`, which has a member t with qualifier `inout(int)`. That don't
make no sense.
You need to chose the static type you are returning. The type *itself* may be
marked as inout. However, that's not what you are doing: You are returning a
type that's parameterized on inout, which is not the same at all.
The idea of "inout" (as I have understood it), is that there is a *single*
implementation that is compatible for all of const/immutable/mutable. That's
not quite what you are doing. I think you simply need a const/non-const
overload. Then, they'll return 2 actual different types "map!(L[])" and
"map!(const(L)[])" (and you can even add an immutable overload if you so wish).
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list