// // Copyright (c) 2002 by Stephen C. Dewhurst // Permission to use, copy, modify, distribute and sell this software for any purpose is // hereby granted without fee, provided that the above copyright notice appears in all copies // and that both that copyright notice and this permission notice appear in supporting documentation. // The author makes no representations about the suitability of this software for any purpose. // It is provided "as is" without express or implied warranty. // // "typeof" operator implementation // // Described in CUJ 20(8, 10, and 12), August, October, and December 2002: "A Bit-Wise Typeof" // This version is a re-write of the original implementation that employs the typeint implementation // of extended precision compile time arithmetic. Typeints are described in CUJ online experts // column, February 2003. // #ifndef UTILS_H #define UTILS_H template struct Int2Int { enum { value = v }; }; // // Type qualifier utilities. // template struct Select { typedef B R; }; template struct Select { typedef A R; }; template struct Deref { typedef T R; }; template struct Deref { typedef T R; }; template struct Deref { typedef T R; }; template struct IsConst { enum { r = false }; }; template struct IsConst { enum { r = true }; }; template struct IsPtr { enum { r = false }; }; template struct IsPtr { enum { r = true }; }; template struct IsPtr { enum { r = true }; }; template struct IsPtr { enum { r = true }; }; template struct IsPtr { enum { r = true }; }; template struct DeConst { typedef T R; }; template struct DeConst { typedef T R; }; template struct IsVol { enum { r = false }; }; template struct IsVol { enum { r = true }; }; template struct DeVol { typedef T R; }; template struct DeVol { typedef T R; }; template struct IsQual { enum { r = IsConst::r || IsVol::r }; }; template struct DeQual { typedef typename DeVol::R>::R R; }; #endif