Skip to content

Instantly share code, notes, and snippets.

@asit-dhal
Created December 4, 2020 20:04
Show Gist options
  • Save asit-dhal/73929c638cb57f5a90299d0aa230d797 to your computer and use it in GitHub Desktop.
Save asit-dhal/73929c638cb57f5a90299d0aa230d797 to your computer and use it in GitHub Desktop.
struct RetVal
{
int x;
int& y;
const int& z;
};
RetVal doSomething(int& a, const int &b) {
return {10, a, b};
}
int main()
{
int a = 100;
auto [m, n, o] = doSomething(a, 200);
assert(m == 10);
assert(n == 100);
assert(o == 200);
assert((std::is_same_v<decltype(m), int>));
assert((std::is_same_v<decltype(n), int&>));
assert((std::is_same_v<decltype(o), const int&>));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment