You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
[...]
structHolder { S s; int i; };
Holder get_Holder() { return {}; }
[...]
S get_S() {
auto [s, i] = get_Holder(); /// structured bindingsauto 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
The text was updated successfully, but these errors were encountered:
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 toBut that would mean
s
is a reference, which is not how I understandauto [s, i]
to behave. Indeed,std::is_reference_v<decltype(s)>
says it's not a reference:Output:
So, I seem to not get something here. Do you have a guess on what's up?
Cheers & thanks for your time, man
The text was updated successfully, but these errors were encountered: