简体   繁体   English

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

[英]boost scoped_lock object in if statement evaluation

The following code compiles 以下代码编译

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

Since lock is an object what happens inthe if (!lock) . 由于lock是一个对象,因此if(!lock)会发生什么。 Does any overloaded function gets called. 是否执行任何重载函数。

operator unspecified_bool_type() const; , which returns owns() , will be called ,它返回owns() ,将被调用

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM