Gli oggetti all'interno dell'oggetto con valore di riferimento valgono anche i valori di riferimento?Gli oggetti all'interno dell'oggetto con valore di riferimento valgono anche i valori di riferimento?
struct A{
};
struct B{
A a2;
};
//template<class B>
void test(B &&b){
// 1. Is this the correct way?
auto &&in3 = std::forward<B>(b).a2;
std::cout << std::is_rvalue_reference<decltype(in3)>::value;
// return true
// 2. or this?
auto &&in4 = b.a2;
std::cout << std::is_rvalue_reference<decltype(in4)>::value;
// return false
}
test(B());
http://coliru.stacked-crooked.com/a/bcf0f7dc4cc0440e
Il problema sembra essere chiariti ulteriormente [qui] (http://open-std.org/jtc1/sc22/wg21 /docs/cwg_defects.html#616). –