Bug 5898 – [const] std.typecons.Rebindable.get() should be const-correct

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-04-27T07:50:00Z
Last change time
2011-10-10T19:40:10Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
kennytm

Comments

Comment #0 by kennytm — 2011-04-27T07:50:31Z
Currently std.typecons.Rebindable.get() is not a const function. This makes the a rebindable member not usable in a const function, e.g. ------------------------------------------ import std.typecons; class Y { string t; } class X { Rebindable!(const(Y)) y; override string toString() const { return y.t; // Error } } ------------------------------------------ x.d(8): Error: function std.typecons.Rebindable!(const(Y)).Rebindable.get () is not callable using argument types () ------------------------------------------ There should be a const get() method, e.g. diff --git a/std/typecons.d b/std/typecons.d index 7d130ca..bbf7615 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -920,6 +920,9 @@ template Rebindable(T) if (is(T == class) || is(T == interface) || isArray!(T)) @property ref T get() { return original; } + @property const(T) get() const { + return original; + } alias get this; }
Comment #1 by k.hara.pg — 2011-10-10T19:40:10Z