// // 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 or 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" // #ifndef UTILS_H #define UTILS_H // // Some utilities that will prove useful. // These are borrowed from Loki. // template struct Select { enum { result = cond }; typedef A Result; }; template struct Select { enum { result = false }; typedef B Result; }; template struct Int2Int { enum { value = v }; }; // // Type qualifier utilities. // template struct IsConst { enum { result = false }; }; template struct IsConst { enum { result = true }; }; template struct DeConst { typedef T R; }; template struct DeConst { typedef T R; }; template struct IsVol { enum { result = false }; }; template struct IsVol { enum { result = true }; }; template struct DeVol { typedef T R; }; template struct DeVol { typedef T R; }; template struct IsQual { enum { result = IsConst::result || IsVol::result }; }; template struct DeQual { typedef typename DeVol::R>::R R; }; #endif