-
-
Save Zshazz/6198938b9c6d40a53ca1 to your computer and use it in GitHub Desktop.
NonNull struct test result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import NonNull, std.stdio; | |
// NonNull struct is located here: | |
// http://forum.dlang.org/thread/wspawctazpndhvdiouhz@forum.dlang.org | |
class Foo { | |
void stuff() { | |
writeln("Hi"); | |
} | |
mixin TRef!(typeof(this)); | |
} | |
void refThing(Ref!Foo f) { | |
f.stuff(); | |
} | |
void thing(Foo f) { | |
f.stuff(); | |
} | |
void main() { | |
Ref!Foo myRefFoo = new Foo; | |
Foo myFoo = new Foo; | |
//myFoo.thing(); // works if mixin TRef!(typeof(this)) is commented above | |
//myRefFoo.refThing(); | |
// if mixin commented-> Error: function expected before (), not refThing(myRefFoo) of type void | |
// otherwise-> Error: forward reference to inferred return type of function call this._obj.getRef("C:\\D\\dmd2\\windows\\bin\\..\\..\\src\\phobos\\std\\typecons.d",2847u).opDispatch() | |
// Error: template instance NonNull.Ref!(Foo).Ref.Proxy!(_obj).opDispatch!("refThing").opDispatch!(Ref!(Foo)) error instantiating | |
//myRefFoo.thing(); | |
// if mixin commented-> Error: function main.thing (Foo f) is not callable using argument types (Ref!(Foo)) | |
// Error: cannot implicitly convert expression (myRefFoo) of type Ref!(Foo) to main.Foo | |
// otherwise -> same as myRefFoo.refThing() | |
//myFoo.refThing(); | |
// same as myRefFoo.thing(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment