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

Jacob Carlborg doob at me.com
Thu Feb 28 00:05:19 PST 2013


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.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list