typeof function literals which define the types of its parameters but do not give their parameters names
Steven Schveighoffer
schveiguy at gmail.com
Thu Dec 27 16:05:39 UTC 2018
On 12/27/18 10:53 AM, Adam D. Ruppe wrote:
> On Thursday, 27 December 2018 at 15:39:23 UTC, Steven Schveighoffer wrote:
>> A template evaluating to a type void is how
>> is(typeof(someTemplateDefinition)) works.
>
> Yeah, I know of that, but with __traits(isTemplate) now, I don't think
> there's any good reason to use the old hack detection anymore anyway.
Yeah, there's definitely ways to work around the limitation.
__traits(compiles) might also help as well.
The real question is, does the current behavior lead to many bugs? If
not, then even though it's a hack, it's not a harmful one.
One possibility I can think of is a function foo that takes a string
delegate, you may expect this to work:
is(typeof(foo((string) {})))
When really you meant this:
is(typeof(foo((string s) {})))
But I wonder how often such a thing happens in practice.
-Steve
More information about the Digitalmars-d-learn
mailing list