X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2Fcml%2Fet%2Fscalar_promotions.h;h=5c6a4a1bc60aeeb2a4f6b374506dedc2d0c7a43b;hp=bb6f8a271e7eed965376895a5065d21fda7b7b54;hb=40755d4c6251206c18ce4784967d3a910cee096f;hpb=d08114d4e7315636ff62127845150273e0cbf66f diff --git a/src/Moof/cml/et/scalar_promotions.h b/src/Moof/cml/et/scalar_promotions.h index bb6f8a2..5c6a4a1 100644 --- a/src/Moof/cml/et/scalar_promotions.h +++ b/src/Moof/cml/et/scalar_promotions.h @@ -19,9 +19,6 @@ Boost Software License, v1.0 (see cml/LICENSE for details). namespace cml { namespace et { -// #define CML_USE_OLD_SCALAR_PROMOTIONS -#if !defined(CML_USE_OLD_SCALAR_PROMOTIONS) - /* The type promotion code below is a slightly modified version of: * http://ubiety.uwaterloo.ca/~tveldhui/papers/techniques/techniques01.html */ @@ -87,9 +84,14 @@ struct promote2 { template struct promote_trait { + + // Need to remove const-ness: + typedef typename cml::remove_const::type T1_non_const; + typedef typename cml::remove_const::type T2_non_const; + // Handle promotion of small integers to int/unsigned int - typedef typename autopromote_trait::T_numtype T1; - typedef typename autopromote_trait::T_numtype T2; + typedef typename autopromote_trait::T_numtype T1; + typedef typename autopromote_trait::T_numtype T2; // True if T1 is higher ranked enum { @@ -140,101 +142,6 @@ template struct ScalarPromote typedef typename detail::promote_trait::T_promote type; }; -#else - -namespace detail { - -/** @class IntPromote - * @brief Helper template to int-promote a type. - */ -template struct IntPromote -{ - /* Signed -> signed int, unsigned -> unsigned int: */ - typedef typename select_switch::result result; -}; - -} // namespace detail - -/** @class ScalarPromote - * @brief Template for compile-time type promotion via C promotion rules. - */ -template struct ScalarPromote -{ - /* Integral-promote the types (if possible). */ - typedef typename detail::IntPromote::result E1; - typedef typename detail::IntPromote::result E2; - - /* If sizeof(long) == sizeof(unsigned int), promote to unsigned long. - * Otherwise, sizeof(long) > sizeof(int), so promote to long. - */ - typedef typename select_if::result uint_promotion; - - /* Do the selection on the promoted types: */ - typedef typename select_switch< - type_pair, - -#if defined(CML_USE_LONG_DOUBLE) - type_pair, long double, - type_pair, long double, - type_pair, long double, -#endif - - type_pair, double, - type_pair, double, - type_pair, double, - - type_pair, float, - type_pair, float, - type_pair, float, - - type_pair, void - - >::result float_filter; - - /* The promoted integral types really matter here: */ - typedef typename select_switch< - type_pair, - - type_pair, unsigned long, - type_pair, unsigned long, - type_pair, unsigned long, - - type_pair, long, - type_pair, uint_promotion, - type_pair, uint_promotion, - - type_pair, long, - type_pair, long, - - type_pair, unsigned int, - type_pair, unsigned int, - type_pair, unsigned int, - - type_pair, int, - type_pair, int, - type_pair, int, - - type_pair, void - - >::result int_filter; - - /* Deduce the final type: */ - typedef typename select_if< - same_type::is_true, - int_filter, float_filter>::result type; -}; -#endif - } // namespace et } // namespace cml