Better Return Value for findSplit*()

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 16 03:28:10 PDT 2015


On Saturday, 16 May 2015 at 09:56:22 UTC, Jakob Ovrum wrote:
> It can be implemented in a backwards-compatible way as a 
> subtype of a Tuple.
>
> struct FindSplit(R)
> {
>     Tuple!(R, "pre", R, "separator", R, "post") asTuple;
>
>     bool opCast(T : bool)()
>     {
>         return !asTuple.separator.empty;
>     }
>
>     alias asTuple this;
> }
>
> Tuple!(R, "pre", R, "separator", R, "post") is a subtype of 
> Tuple!(R, R, R), which should be the current return type.

Nice! Should I make a PR?


More information about the Digitalmars-d-learn mailing list