Encapsulate return value in scoped

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 11 10:34:55 PDT 2015


On 6/11/15 1:28 PM, Yuxuan Shui wrote:
> On Thursday, 11 June 2015 at 09:11:47 UTC, Daniel Kozák wrote:
>>
>> On Thu, 11 Jun 2015 09:01:04 +0000
>> Yuxuan Shui via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com>
>> wrote:
>>>     A x = scoped!A(10);
>>
>> use auto x = scoped!A(10);
>
> Thanks!
>
> Curious question, why doesn't compiler reject this code?

Because scoped!A implicitly casts to A.

-Steve


More information about the Digitalmars-d-learn mailing list