Template constraints should introduce identifiers inside their scopes
Paul Backus
snarwin at gmail.com
Thu Sep 22 18:00:53 UTC 2022
On Thursday, 22 September 2022 at 16:52:54 UTC, Timon Gehr wrote:
> On 21.09.22 14:32, Paul Backus wrote:
>>>
>>> They are not semantically the same. The first can be
>>> instantiated with any type and conditionally makes an output
>>> (it is empty otherwise), the other says it cannot be
>>> instantiated unless the arguments have specific properties.
>>
>> If you want the semantics to match exactly you can replace the
>> `static if` with a `static assert` (or add `else static
>> assert(0);`).
>
> I think this is not true.
>
[...]
>
> `static assert` can give you a custom error message, but
> template constraints have much better overloading behavior. The
> two features are not comparable.
In general, yes. In the context of the specific example in this
thread, they are the same. In any case, the difference has no
bearing on the main topic of discussion here, which is name
visibility.
More information about the Digitalmars-d
mailing list