我想问一下有关将类型转换为T&&and 的问题const T&。
int&& ref = static_cast<int&&>(1); // will ref assign to free memory? or
const int& ref = static_cast<const int&>(1);
Run Code Online (Sandbox Code Playgroud)
int&& func() {
return 1;
}
// or
int&& func() { // call of this function always return free memory?
return static_cast<int&&>(1);
}
Run Code Online (Sandbox Code Playgroud)
// does static_cast<> have some different forms from casting int() (int) ?
static_cast<int&&>(1),
static_cast<const int&>(1),
or func(); // do I understand right, reference destroys with object after ';' or it returns free …Run Code Online (Sandbox Code Playgroud)