Skip to content
Create a gist now

Instantly share code, notes, and snippets.

@Zshazz /main.d secret

NonNull struct test result
import NonNull, std.stdio;
// NonNull struct is located here:
class Foo {
void stuff() {
mixin TRef!(typeof(this));
void refThing(Ref!Foo f) {
void thing(Foo f) {
void main() {
Ref!Foo myRefFoo = new Foo;
Foo myFoo = new Foo;
//myFoo.thing(); // works if mixin TRef!(typeof(this)) is commented above
// 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
// 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()
// same as myRefFoo.thing();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.