Thread overview
[Issue 19129] std.typecons.scoped crashes when used on classes that have context
Jul 30, 2018
Simen Kjaeraas
Aug 16, 2018
Seb
Sep 20, 2018
Simen Kjaeraas
Dec 17, 2022
Iain Buclaw
July 30, 2018
https://issues.dlang.org/show_bug.cgi?id=19129

Simen Kjaeraas <simen.kjaras@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras@gmail.com

--- Comment #1 from Simen Kjaeraas <simen.kjaras@gmail.com> ---
This issue is also present in std.conv.emplace (which scoped uses internally).

At least currently, it is impossible to get a good value for the context pointer:

unittest {
    int y;
    class C { this(int x) { y = x; } }
    create!C();
}

T create(T)() {
    // outer function context of foo.__unittest_L1_C1 is
    // needed to new nested class foo.__unittest_L1_C1.C
    return new T(0);
}

emplace already checks for isInnerClass!T, and should also check for nested, non-inner classes. std.traits should have a trait that checks for this (hasContext? isNestedClass sounds like it should include isInnerClass).

--
August 16, 2018
https://issues.dlang.org/show_bug.cgi?id=19129

Seb <greensunny12@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |greensunny12@gmail.com

--
September 20, 2018
https://issues.dlang.org/show_bug.cgi?id=19129

--- Comment #2 from Simen Kjaeraas <simen.kjaras@gmail.com> ---
template hasContextPointer(T)
{
    struct S(Fields...)
    {
        Fields f;
    }
    enum fieldSize = S!(typeof(T.tupleof)).sizeof;
    static if (is(T == class))
    {
        enum hasContextPointer = __traits(classInstanceSize, T) > fieldSize +
size_t.sizeof*2 -1;
    }
    else
    {
        enum hasContextPointer = T.sizeof > fieldSize;
    }
}

--
January 30, 2019
https://issues.dlang.org/show_bug.cgi?id=19129

johanengelen@weka.io changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |industry
                 CC|                            |johanengelen@weka.io

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=19129

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

--