Why invariants in D 2.0 std.string?

Bruce Adams tortoise_74 at yeah.who.co.uk
Wed Oct 31 13:59:19 PDT 2007


Janice Caron Wrote:

[good stuff snipped]

> That's cool. It works for any kind of string. But the pre-existing
> functions are still chars only. For example, tolower is still:
>     invariant(char)[] tolower(invariant(char)[] s)
> 
> instead of, as one might hope:
>     S tolower(S)(S s)
>
I agree. I expect is awaiting evolution. That part of phobos predates templates after all.
 
> Of course, that said, I'm not completely sure how one would specify
> that a template type must be tail-invariant! Maybe:
>     invariant(C)[] tolower(C)(invariant(C)[] s)
> ?
> 
I'm guessing the answer involves chaining alias templates to produce a 
"static_assert(IsTailInvariant(C) == true);"




More information about the Digitalmars-d mailing list