Template Trick
Ali Çehreli
acehreli at yahoo.com
Wed Jun 12 15:10:51 PDT 2013
On 06/12/2013 02:56 PM, matovitch wrote:
> On Wednesday, 12 June 2013 at 21:52:46 UTC, Ali Çehreli wrote:
>>
>> Here is one way:
>>
>> void func(V, alias def_val) (uint i, V v)
>> if (is (typeof(def_val == V.type)))
Oops. It should be:
if (is (typeof(def_val) == V.type))
Hmmm. How come the other one worked as well? Because the type of
(def_val == V.type) is compiled as bool and since bool is a valid type,
'is' passes.
>> {
>> if (i < v.dimension) {
>> v.data[i] = def_val;
>> }
>> }
>>
>> Ali
>
> Thank you !
Ali
More information about the Digitalmars-d-learn
mailing list