#if !defined(spp_traits_h_guard) #define spp_traits_h_guard #include template class HashObject; // for Google's benchmark, not in spp namespace! namespace spp_ { // --------------------------------------------------------------------------- // type_traits we need // --------------------------------------------------------------------------- template struct integral_constant { static const T value = v; }; template const T integral_constant::value; typedef integral_constant true_type; typedef integral_constant false_type; typedef integral_constant zero_type; typedef integral_constant one_type; typedef integral_constant two_type; typedef integral_constant three_type; template struct is_same : public false_type { }; template struct is_same : public true_type { }; template struct remove_const { typedef T type; }; template struct remove_const { typedef T type; }; template struct remove_volatile { typedef T type; }; template struct remove_volatile { typedef T type; }; template struct remove_cv { typedef typename remove_const::type>::type type; }; // ---------------- is_integral ---------------------------------------- template struct is_integral; template struct is_integral : false_type { }; template<> struct is_integral : true_type { }; template<> struct is_integral : true_type { }; template<> struct is_integral : true_type { }; template<> struct is_integral : true_type { }; template<> struct is_integral : true_type { }; template<> struct is_integral : true_type { }; template<> struct is_integral : true_type { }; template<> struct is_integral : true_type { }; template<> struct is_integral : true_type { }; template<> struct is_integral : true_type { }; #ifdef SPP_HAS_LONG_LONG template<> struct is_integral : true_type { }; template<> struct is_integral : true_type { }; #endif template struct is_integral : is_integral { }; template struct is_integral : is_integral { }; template struct is_integral : is_integral { }; // ---------------- is_floating_point ---------------------------------------- template struct is_floating_point; template struct is_floating_point : false_type { }; template<> struct is_floating_point : true_type { }; template<> struct is_floating_point : true_type { }; template<> struct is_floating_point : true_type { }; template struct is_floating_point : is_floating_point { }; template struct is_floating_point : is_floating_point { }; template struct is_floating_point : is_floating_point { }; // ---------------- is_pointer ---------------------------------------- template struct is_pointer; template struct is_pointer : false_type { }; template struct is_pointer : true_type { }; template struct is_pointer : is_pointer { }; template struct is_pointer : is_pointer { }; template struct is_pointer : is_pointer { }; // ---------------- is_reference ---------------------------------------- template struct is_reference; template struct is_reference : false_type {}; template struct is_reference : true_type {}; // ---------------- is_relocatable ---------------------------------------- // relocatable values can be moved around in memory using memcpy and remain // correct. Most types are relocatable, an example of a type who is not would // be a struct which contains a pointer to a buffer inside itself - this is the // case for std::string in gcc 5. // ------------------------------------------------------------------------ template struct is_relocatable; template struct is_relocatable : integral_constant::value || is_floating_point::value)> { }; template struct is_relocatable > : true_type { }; template struct is_relocatable : is_relocatable { }; template struct is_relocatable : is_relocatable { }; template struct is_relocatable : is_relocatable { }; template struct is_relocatable : is_relocatable { }; template struct is_relocatable > : integral_constant::value && is_relocatable::value)> { }; // A template helper used to select A or B based on a condition. // ------------------------------------------------------------ template struct if_ { typedef A type; }; template struct if_ { typedef B type; }; } // spp_ namespace #endif // spp_traits_h_guard