Problems with "shared"

Satoshi via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Oct 9 23:43:09 PDT 2016


On Sunday, 9 October 2016 at 21:32:23 UTC, ag0aep6g wrote:
> On 10/09/2016 10:57 PM, jython234 wrote:
>> 1. Where do I use the "shared" keyword?
>
> What doesn't work is creating an unshared object of a class 
> that only has a shared constructor. To create both shared and 
> unshared objects, you need either two constructors or a `pure` 
> one.
>
>     class C
>     {
>         this() pure {}
>     }
>     void main()
>     {
>         auto u = new C; /* works */
>         auto s = new shared C; /* too */
>     }
>


Why this ins't in doc? :O I didn't know about using pure in this 
way.


More information about the Digitalmars-d-learn mailing list