在if语句评估中提升scoped_lock对象

时间:2014-04-23 15:59:18

标签: c++ boost

以下代码编译

scoped_lock<named_mutex> lock(some_mutex);
if (!lock) { // What does this means, which function is called
}

因为锁是一个对象,所以在 if(!lock)中会发生什么。是否会调用任何重载函数。

1 个答案:

答案 0 :(得分:2)

返回operator unspecified_bool_type() const;

owns()将被称为

http://live.boost.org/doc/libs/release/doc/html/boost/interprocess/scoped_lock.html