64,648
社区成员
发帖
与我相关
我的任务
分享
scoped_ptr<string> pStr(new string("Ding Ding"));
cout << pStr << endl;
typedef T * this_type::*unspecified_bool_type;
operator unspecified_bool_type() const
{
return px == 0? 0: &this_type::px;
}
// typedef 成 bool_type,而不是 member_ptr ,从命名来看,代码作者的意思就是当成bool的吧
// 另外,cout << pStr , 也是进入这一段代码的。
typedef T * this_type::*unspecified_bool_type;
operator unspecified_bool_type() const // 这就是源码,就是当做bool来用了啊?
{ // if (pStr)也是跳进这里执行的。
return px == 0? 0: &this_type::px;
}
// 这不就是把“指向成员的指针”当做“bool”来用吗?非常不解?
typedef T * this_type::*unspecified_bool_type;
operator unspecified_bool_type() const // 返回值是bool吗?
{
return px == 0? 0: &this_type::px;
}