_cast<A*>(this), this){}};structBase{virtual~Base(){}};structDerived:Base{virtualvoidname(){}};intmain(){D d;// 最终派生对象A&a=d;// 向上转换,可以用 dynamic_cast,但不是必须的[[maybe_unused]]D&new_d=dynamic_cast<D&>(a);// 向下转换[[maybe_unused]]B&new_b=dynamic_cast<...
static_cast 转换一个类型为另一相关类型 dynamic_cast 在继承层级中转换 const_cast 添加或移除 cv 限定符 reinterpret_cast 转换类型到无关类型 C 风格转换 以static_cast、const_cast 及reinterpret_cast 的混合转换一个类型到另一类型 new 创建有动态存储期的对象 delete 销毁先前由 new 表达式创建的对象,并释...
dynamic_cast and polymorphic typeid in constant expressions P1327R1 10 9 19.29 (16.10)* 11.0.3* 5.1 2021.1 20.7 12.0 11.0 Changing the active member of a union inside constexpr [FTM]* P1330R0 9 9 19.10* 11.0.3* 5.1 2021.1 20.7 12.0 11.0 Coroutines [FTM]* P0912R5 10 8 (partial...
5.4 Explicit type conversion (cast notation) [expr.cast] See also const_castconversionadds or removes const static_castconversionperforms basic conversions dynamic_castconversionperforms checked polymorphic conversions reinterpret_castconversionperforms general low-level conversions ...
6) 强转为“对象的右值引用”表达式,比如,static_cast<char&&>(x)。 x值表达式的属性[properties]: 1) 拥有右值[rvalue]表达式的所有属性。 2) 拥有左值[glvalue]表达式的所有属性。 [注] 类似于纯右值,x值绑定右值引用,但不同的是,x值可能是多态的[polymorphic],并且非类[non-class]的x值可能被const或...
static_cast conversion dynamic_cast conversion reinterpret_cast conversion C-Stil und funktionale Besetzung Speicherzuweisung Original: Memory allocation The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. new ...
C++ keyword:const_cast C++ C++ language if switch for while continue-break goto-return decltype auto constexpr consteval constinit --nullptr static_cast const_cast dynamic_cast reinterpret_cast explicit static Keywords Usage const_casttype conversion expression: as the declaration of the expression ...
constexpr consteval constinit --nullptr static_cast const_cast dynamic_cast reinterpret_cast explicit static Keywords Usage reinterpret_casttype conversion expression: as the declaration of the expression See also const_cast dynamic_cast static_cast...
a cast expression to rvalue reference to function type, such as static_cast<void (&&)(int)>(x). (C++ 11 右值强转函数类型) Properties: Same as glvalue (below). Address of an lvalue may be taken: &++i[1] and &std::endl are valid expressions. ...
a cast expression to non-reference type, such as static_cast(x), std::string{}, or (int)42; the this pointer; (this指针也是纯右值,因为this也是一个地址) a lambda expression, such as [](int x){ return x * x; }.(since C++11) ...