获取指向该指定的值的指针。
Ty *operator->() const;
备注
选择运算符返回 get(),因此表达式,sp->member 的行为与 sp 是类 shared_ptr<Ty>对象的 (sp.get())->member 相同。 因此,内存的指针不能是空的,因此,Ty 必须为类、结构或联合类型与成员 member。
示例
// std_tr1__memory__shared_ptr_operator_ar.cpp
// compile with: /EHsc
#include <memory>
#include <iostream>
typedef std::pair<int, int> Mypair;
int main()
{
std::shared_ptr<Mypair> sp0(new Mypair(1, 2));
std::cout << "sp0->first == " << sp0->first << std::endl;
std::cout << "sp0->second == " << sp0->second << std::endl;
return (0);
}
要求
页眉: <内存>
命名空间: std