"Fossies" - the Fresh Open Source Software Archive

Member "ldc-1.10.0-src/tests/d2/dmd-testsuite/runnable/imports/a15079.d" (19 Jun 2018, 864 Bytes) of package /linux/misc/ldc-1.10.0-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) D source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 module imports.a15079;
    2 
    3 Vector!string parseAlgorithmName()
    4 {
    5     assert(0);
    6 }
    7 
    8 struct Vector(ALLOC)
    9 {
   10     @disable this(this);
   11 
   12     RefCounted!(Vector, ALLOC) dupr()
   13     {
   14         assert(0);
   15     }
   16 }
   17 
   18 struct RefCounted(T, ALLOC)
   19 {
   20     ~this()
   21     {
   22         T* objc;
   23         .destroy(*objc);
   24     }
   25 }
   26 
   27 // ----
   28 
   29 void _destructRecurse(S)(ref S s)
   30     if (is(S == struct))
   31 {
   32     static if (__traits(hasMember, S, "__xdtor") &&
   33                __traits(isSame, S, __traits(parent, s.__xdtor)))
   34     {
   35         s.__xdtor();
   36     }
   37 }
   38 
   39 void destroy(T)(ref T obj) if (is(T == struct))
   40 {
   41     _destructRecurse(obj);
   42     () @trusted {
   43         auto buf = (cast(ubyte*) &obj)[0 .. T.sizeof];
   44         auto init = cast(ubyte[])typeid(T).init();
   45         if (init.ptr is null) // null ptr means initialize to 0s
   46             buf[] = 0;
   47         else
   48             buf[] = init[];
   49     } ();
   50 }