小编Kap*_*ppy的帖子

static_cast<T&&> 和 static_cast<const T&>

我想问一下有关将类型转换为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)

c++ casting reference

1
推荐指数
1
解决办法
86
查看次数

标签 统计

c++ ×1

casting ×1

reference ×1