[Issue 16171] New: std.experimental.allocator.make does not respect private class constructors

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jun 14 03:53:32 PDT 2016


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

          Issue ID: 16171
           Summary: std.experimental.allocator.make does not respect
                    private class constructors
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: joeyemmons at yahoo.com

Allocator make with no extra args works on classes even when default
construction is not available. 

import other;
import std.experimental.allocator;
import std.experimental.allocator.mallocator;
void main(){
    // auto t1 = new test(); // Error 
    auto t = Mallocator.instance.make!test(); // Works
}

...

module other;
class test{
    private this(){
    }
}


Worse even is it will still work even if class test does not have a default
constructor at all.

module other;
class test{
    private this(int i){
             // No default constructor... 
    }
}

--


More information about the Digitalmars-d-bugs mailing list