Skip to content

Instantly share code, notes, and snippets.

@isaac-weisberg
Last active November 11, 2018 04:39
Show Gist options
  • Select an option

  • Save isaac-weisberg/ed0ea3d7ef3512e64c3b40904f215b4e to your computer and use it in GitHub Desktop.

Select an option

Save isaac-weisberg/ed0ea3d7ef3512e64c3b40904f215b4e to your computer and use it in GitHub Desktop.
auto foo() {
class Bar {
public:
int baz;
};
Bar ret;
ret.baz = 3;
return ret;
}
void usage() {
// Can not reference the returned value by anything BUT auto
// however the compiler is absolutely aware of the returned
// object's structure
auto val = foo();
int baz = val.baz; // 3
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment