Bug 4978 – Can't get object out of Rebindable: get is private

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-10-02T18:09:00Z
Last change time
2015-06-09T05:15:21Z
Assigned to
nobody
Creator
issues.dlang

Comments

Comment #0 by issues.dlang — 2010-10-02T18:09:00Z
This code import std.typecons; class T { this() immutable { } } void main() { immutable orig = new T(); auto bound = rebindable(orig); immutable backOut = bound.get; } results in this compilation error: d.d(14): Error: struct std.typecons.Rebindable!(immutable(T)).Rebindable member original is not accessible d.d(14): Error: struct std.typecons.Rebindable!(immutable(T)).Rebindable member original is not accessible As far as I can determine, get is the intended way to get the object out Rebindable!() (I certainly can't see any other way), but it doesn't work. And really, I see no point to get if it won't get you the object bound by Rebindable!(). I think that get needs to be a property which returns original rather than just an alias. The alias isn't working, and it makes really hard to use Rebindable!() when you don't want to be passing Rebindable!() around everywhere.
Comment #1 by issues.dlang — 2010-10-02T18:14:08Z
Also, the static ifs at the top are missing any kind of get, so you can't use get generically with Rebindable. Perhaps what should be done instead is to have on opCast() which casts to the original. That would work with the first static if - and obviously the struct in the else - but I'm not sure that it would work with the second one since it's const when the original could have been immutable. It is a potential concern though.
Comment #2 by schveiguy — 2010-10-04T06:15:59Z
*** This issue has been marked as a duplicate of issue 3318 ***