May 18, 2013 Re: Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | On Saturday, 18 May 2013 at 08:19:59 UTC, Dicebot wrote:
> On Saturday, 18 May 2013 at 02:34:46 UTC, Andrej Mitrovic wrote:
>> On 5/18/13, Timothee Cour <thelastmammoth@gmail.com> wrote:
>>> S.init should be known at compile time by the spec.
>>
>> But why is this needed?
>
> It is quite helpful for template / meta-programming stuff. You are always 100% guaranteed that you can construct S.init and use with your weird template magic wihtout extra checks and fallbacks. However, so far most of real-world usages of T.init I have seen is more about template constraint checks where exact T.init value does not matter that much. Any other usage examples in mind?
Within phobos it is used quite heavily.
|
Copyright © 1999-2021 by the D Language Foundation