Tuesday, February 13, 2007

addressof


The address of an object can be retrieved without using the address-of operator with the following function template:

template<typename T>

T * addressof(T & v)

{

  return reinterpret_cast<T*>( &const_cast<char&>( reinterpret_cast<const volatile char &>( v ) ) );

}





No comments:

CBOE Put/Call Ratio