Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module foo;
- import std.stdio;
- class Foo
- {
- private this ()
- {
- writeln("ads");
- }
- }
- module test;
- import std.stdio;
- import foo;
- version (LDC)
- extern (C) Object _d_allocclass(ClassInfo);
- else
- extern (C) Object _d_newclass(ClassInfo);
- Object newInstance (ClassInfo classInfo)
- {
- version (LDC)
- {
- Object object = _d_allocclass(classInfo);
- (cast(byte*) object)[0 .. classInfo.init.length] = classInfo.init[];
- return object;
- }
- else
- return _d_newclass(classInfo);
- }
- void main()
- {
- auto f = cast(Foo) newInstance(Foo.classinfo);
- auto a = &f.__ctor;
- a();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement