Array append performance 2

dsimcha dsimcha at yahoo.com
Sat Aug 30 18:32:58 PDT 2008


== Quote from bearophile (bearophileHUGS at lycos.com)'s article
> IsReferenceType!() isn't fully correct because it sees fixed size arrays as
reference types. I have posted a more correct (and cleaned, and single-template)
version here:
>
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=75813
> Bye,
> bearophile

One small issue:  Your IsReference template doesn't work with invariant, and
presumably const, types.  For example,

IsReferenceType!(typeof("Foo"[0]));  //Returns true.

The easiest way to fix this is to add a Mutable!():

static if (IsType!(Mutable!(Types[0]), bool, byte, ubyte, short, ushort, int, uint,
                           long, ulong, float, double, real, ifloat, idouble,
                           ireal, cfloat, cdouble, creal, char, dchar, wchar) )

Also, although it may be the least bad way to do this (I can't think of a better
one), the process of elimination method this relies on seems kind of brittle
because it would have to be modified for any new type that is added.  If anyone
knows of a less kludge-y way, please post.



More information about the Digitalmars-d mailing list