statement in boost lib, (void)p; what does it mean?
I came across following piece of code in Boost Library for offset_ptr. under boost/interprocess/offset_ptr.hpp
typedef PointedType * pointer;
...
//!Constructor from other pointer.
//!Neve开发者_StackOverflowr throws.
template <class T>
offset_ptr(T *ptr)
{ pointer p (ptr); (void)p; this->set_offset(p); }
I wonder what does a statement (void)p; does?
One way to find out is to put a break point on that line of code and step through to find out what it does. You can even reformat the code to allow you to set the break point on that particular statement (there's no law against editing these files - just don't change the actual code).
However, my guess is that the pointer
type is using some form of lazy evaluation, the emulated cast operators call a set_offset
method so maybe the this->set_offset(p)
requires p
to have a valid offset set up and doing the (void)p
just forces it to happen.
精彩评论