Created
December 4, 2020 20:04
-
-
Save asit-dhal/73929c638cb57f5a90299d0aa230d797 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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