r-the pointer to convert Notes The expressionsstd::shared_ptr<T>(static_cast<T*>(r.get())),std::shared_ptr<T>(dynamic_cast<T*>(r.get()))andstd::shared_ptr<T>(const_cast<T*>(r.get()))might seem to have the same effect, but they all will likely result in undefined behavior...
调用右值重载(2,4,6,8)后,r为空且r.get()==nullptr,但对于dynamic_pointer_cast(4),若dynamic_cast失败则不修改r。 (C++20 起) 参数 r-要转换的指针 注解 表达式std::shared_ptr<T>(static_cast<T*>(r.get()))、std::shared_ptr<T>(dynamic_cast<T*>(r.get()))及std::shared_ptr<T>(con...
指向任意类型对象的指针都可以被隐式转换成指向void 的指针(可有 cv 限定);它的值不会改变。逆向的转换要求 static_cast 或显式转换,并生成它的原指针值: int n = 1; int* p1 = &n; void* pv = p1; int* p2 = static_cast<int*>(pv); std::cout << *p2 << '\n'; // 打印 1如果原...
static_pointer_castdynamic_pointer_castconst_pointer_castreinterpret_pointer_cast appliesstatic_cast,dynamic_cast,const_cast, orreinterpret_castto the stored pointer (function template) Helper classes std::hash<std::experimental::shared_ptr> hash support forstd::experimental::shared_ptr ...
4)a.*mp, 对象的成员指针表达式[the pointer to member of object expression]。其中,‘a’是右值,‘mp’是指向数据成员的指针。 5) a?b:c, a ? b : c, 对于某些a,b,c的三元条件表达式[ternary conditional expression]。 6) 强转为“对象的右值引用”表达式,比如,static_cast<char&&>(x)。
static_castconverts one type to another related type dynamic_castconverts within inheritance hierarchies const_castadds or removescv-qualifiers reinterpret_castconverts type to unrelated type C-style castconverts one type to another by a mix ofstatic_cast,const_cast, andreinterpret_cast ...
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) ...
intrusive_ptr< T >static_pointer_cast(intrusive_ptr< U > const &p) template<class T , class U > intrusive_ptr< T >const_pointer_cast(intrusive_ptr< U > const &p) template<class T , class U > intrusive_ptr< T >dynamic_pointer_cast(intrusive_ptr< U > const &p) ...
pointer = new type; pointer = new type( initializer ); pointer = new type[size]; new可以给数据类型分配一个新结点并返回一个指向新分配内存区的首地址. 也可以对它进行初始化.中括号中的size可以分配尺寸大小. delete 语法: return-type class-name::operator#(parameter-list) { ...
Gegossener Ausdruck rvalue Bezugnahme auf Objekttyp, wie static_cast<T&&>(val) oder (T&&)val Original: A cast expression to an rvalue reference to object type, such as static_cast<T&&>(val) or (T&&)val The text has been machine-translated via Google Translate. You can help to cor...