Battle-plan for CTFE
Andrea Fontana via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Wed Oct 26 01:19:46 PDT 2016
On Wednesday, 26 October 2016 at 03:58:05 UTC, Stefam Koch wrote:
> On Tuesday, 25 October 2016 at 17:19:26 UTC, Jacob Carlborg
> wrote:
>>
>> Very impressive :)
>
> Thanks.
>
> I just got the following code to compile and execute correctly.
>
> bool strEq(string a, string b)
> {
> if (a.length != b.length)
> {
> return false;
> }
> uint length = cast(uint) a.length;
>
> while(length--)
> {
> auto c1 = a[length];
> auto c2 = b[length];
> if (c1 != c2)
> {
> return false;
> }
> }
>
> return true;
> }
>
> static assert(!strEq("Hello","World"));
> static assert(strEq("World","World"));
>
> I used the generated bytecode to make == for strings work.
Why did you cast size_t to uint in this example?
More information about the Digitalmars-d-announce
mailing list