Does calling a destructor of an boost::lock object explicitly have any consequence at all?
For instance:
boost::mutex M_;
boost::mutex::scoped_lock SL_(M_);
SL_.~unique_lock();
SL_.unlock();
SL_.lock();
//both of the above work on runtime as if nothing happened to SL_
//note: typedef unique_lock<mutex> scoped_lock;
Asking out of curiosity.
Once you call the destructor of an object allocated on local storage, it is not alive anymore.
Referring to the object members after calling the destructor is an Undefined Behavior.
An Undefined Behavior means that any behavior is possible and does not necessarily mean that your code crashes, but it means you can see incorrect behavior or any random behavior.
So just don’t do that.