[Issue 22334] TypeInfo is used in inexplicable places

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Sep 24 10:47:18 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22334

Max Samukha <maxsamukha at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxsamukha at gmail.com

--- Comment #1 from Max Samukha <maxsamukha at gmail.com> ---
Assigning to an array's length may reallocate, and allocation still needs
TypeInfo. You could try to get away with a lambda (not tested):

alias _ctfeAppend = (store, dat)
{
        alias T = typeof(dat);

        static if (is(T U: const(U)))
        {
            pragma(msg, U);
                U[] buf;
                buf.length = 1;
                buf[0] = dat;
                store = cast(T[])buf;
        }
};

However, the lambda hack is unusable for anything slightly less trivial (no
overloading, if-constraints, variadic parameters, etc.)

--


More information about the Digitalmars-d-bugs mailing list