[Issue 8407] New: Add inout inferrence to member functions in templates
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jul 21 17:28:38 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8407
Summary: Add inout inferrence to member functions in templates
Product: D
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: jmdavisProg at gmx.com
--- Comment #0 from Jonathan M Davis <jmdavisProg at gmx.com> 2012-07-21 17:28:36 PDT ---
In an attempt to make std.range.Cycle const-correct, I had to do stuff like
this:
@property auto ref front()
{
return _original[_index % _original.length];
}
static if (is(typeof((cast(const R)_original)[0])) &&
is(typeof((cast(const R)_original).length)))
{
@property auto const ref front() const
{
return _original[_index % _original.length];
}
}
In the associated review,Aandrei mentioned the possibility of adding const
inferrence to the list of attributes that are inferred for templated member
functions. And I think that this code highlights the need for something along
those lines.
However, given the fact that there are many cases where you want both a
non-const function which returns a non-const result and const function which
returns a const result (as is the case in the example above), I think that
inout inferrence would be a better choice (though if the return type doesn't
have to be const on a const function and inout doesn't work with that, then
inferring const would be fine then).
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list