Returning an empty range of a given type
rcorre via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu May 14 20:22:41 PDT 2015
On Thursday, 14 May 2015 at 14:57:26 UTC, Idan Arye wrote:
> How about a more flexible solution?
>
> http://dpaste.dzfl.pl/2f99cc270651
Neat, thanks!
On Thursday, 14 May 2015 at 18:44:58 UTC, Steven Schveighoffer
wrote:
> It depends on the guts of MyContainer.Range.
>
> I'm assuming MyContainer.Range has SOME sort of references
> (i.e. pointers) to the data in the container, so why not just
> have:
>
> bool empty() { return someRef == null || yourCurrentTest; }
>
> -Steve
In this case, I want to return an empty range when the container
instance itself is null. I could have a static method
MyContainer.emptySlice, but I feel like I've seen this general
situation crop up a lot with small variations.
More information about the Digitalmars-d-learn
mailing list