Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Welcome Guest | Log In | Register | Benefits
Channels ▼
RSS

An Improved Variant Type Based on Member Templates


October 2000/An Improved Variant Type Based on Member Templates/Listing 1

Listing 1: Definition of class variant0_t

struct variant0_t
{
  variant0_t():data(NULL){}

  template<typename T> variant0_t(const T& v)
   : data ( &v ) {}

  template<typename T> operator T () const
  { return * reinterpret_cast<const T*>(data); }

  const void* data ;
} ;


Related Reading


More Insights