-
Notifications
You must be signed in to change notification settings - Fork 178
Open
Description
hey, I love your talks, but one thing had me confused:
In the CppCon2018 talk about object lifetimes, the slides claim that auto [s, i] = get_Holder(); was essentially equivalent to
auto e = get_Holder();
auto& s = e.s;
auto& i = e.i;But that would mean s is a reference, which is not how I understand auto [s, i] to behave. Indeed, std::is_reference_v<decltype(s)> says it's not a reference:
[...]
struct Holder { S s; int i; };
Holder get_Holder() { return {}; }
[...]
S get_S() {
auto [s, i] = get_Holder(); /// structured bindings
auto e = get_Holder();
auto& _s = e.s;
auto& _i = e.i;
std::cout << std::is_reference_v<decltype(s)> << std::is_reference_v<decltype(_s)> <<"\n";
return s;
}Output:
01
So, I seem to not get something here. Do you have a guess on what's up?
Cheers & thanks for your time, man
Metadata
Metadata
Assignees
Labels
No labels