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.
//!Never 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
pointertype is using some form of lazy evaluation, the emulated cast operators call aset_offsetmethod so maybe thethis->set_offset(p)requirespto have a valid offset set up and doing the(void)pjust forces it to happen.