просто чтобы хорошо понимать, что там под капотом... вопросы в коде в виде комментариев
void test(int && val)
{
val=4;
}//val is destroyed here ?
int main()
{
int nb;
test(std::move(nb));
//undefined behavior if I reference here nb ?
std::cout << nb;
nb=5;
std::cin.ignore();
}