Intended to be able to RefCount an interface?

Jakob Ovrum via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 9 21:08:58 PST 2015


On Tuesday, 10 February 2015 at 04:44:55 UTC, weaselcat wrote:
> Thread title.
>
>
> interface Itest{
>
> }
>
> class testclass : Itest{
> }
>
> void main()
> {
>     import std.typecons;
>     auto test = RefCounted!Itest(new testclass());
> }
>
> If you change the refcounted to type testclass it doesn't 
> compile because refcounted doesn't support classes.
>
> Is this a bug, or intended?

I think this is a bug, and that the current RefCounted needs to 
reject interfaces. AFAIK, it is intended that 
RefCounted!SomeClass is supposed to reference-count the actual 
class instance, not its reference, which is what 
RefCounted!SomeInterface currently does.


More information about the Digitalmars-d-learn mailing list