Thread overview
[Issue 16389] "const" should be inferred for template methods
Aug 15, 2016
greenify
Dec 17, 2022
Iain Buclaw
August 15, 2016
https://issues.dlang.org/show_bug.cgi?id=16389

Steven Schveighoffer <schveiguy@yahoo.com> changed:

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

--- Comment #1 from Steven Schveighoffer <schveiguy@yahoo.com> ---
One can do this already, though I agree it would be nice if this was the default:

struct S
{
   int _x;
   int x(this T)() { return _x; }
}

void main()
{
   S s;
   const S cs;
   writeln(s.x, cs.x);
}

--
August 15, 2016
https://issues.dlang.org/show_bug.cgi?id=16389

greenify <greeenify@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |greeenify@gmail.com

--- Comment #2 from greenify <greeenify@gmail.com> ---
> Currently defining const and non-const versions of methods in generic code is redundant and error-prone.

FWIW isn't inout a solution to a similar problem? In any case inout needs rebranding

--
August 15, 2016
https://issues.dlang.org/show_bug.cgi?id=16389

--- Comment #3 from Andrei Alexandrescu <andrei@erdani.com> ---
(In reply to greenify from comment #2)
> > Currently defining const and non-const versions of methods in generic code is redundant and error-prone.
> 
> FWIW isn't inout a solution to a similar problem? In any case inout needs rebranding

Deduction is different because there's no qualifier applied if the method is never used on a const object.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=16389

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
December 13
https://issues.dlang.org/show_bug.cgi?id=16389

--- Comment #4 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19169

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--