Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Container {
- Foo foo = void;
- this() {
- foo = Foo();
- }
- }
- struct Foo {
- void bar() {
- import std.stdio;
- writeln("Foo.bar");
- }
- }
- struct FooBar {
- void* origin;
- void delegate() barFunc;
- void delegate() caller;
- this(Foo* origin) {
- this.origin = origin;
- this.barFunc = &origin.bar;
- barFunc = &callFunc!7;
- }
- void call() {
- caller();
- }
- void callFunc(int foobared)() {
- barFunc();
- }
- }
- void main() {
- Container ctx = new Container;
- FooBar foobar = FooBar(&ctx.foo);
- foobar.call;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement