D as a prototyping language (for C/C++ projects)

deadalnix deadalnix at gmail.com
Thu Feb 28 00:15:03 PST 2013


On Thursday, 28 February 2013 at 08:05:20 UTC, Jacob Carlborg 
wrote:
> On 2013-02-28 04:35, Rob T wrote:
>
>> I had a look at your isBlank function. Why not check if length 
>> exists
>> and run it as follows?
>>
>> @property bool isBlank (T) (T t)
>> {
>>
>>    static if (__traits(compiles, t.length))
>>    {
>>        if (t.length == 0)
>>           return true;
>>    }
>>
>> ...
>>
>> That would be more generic I think.
>
> Sure, I could do that. But I thought checking for "empty" would 
> be more generic. I would expect every type having "length" 
> would/should also have "empty" but perhaps that's a wrong 
> assumption.

It is easy to ensure via UFCS.


More information about the Digitalmars-d mailing list