]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/cml/et/scalar_promotions.h
version bump cml to version 1.0.2
[chaz/yoink] / src / Moof / cml / et / scalar_promotions.h
index bb6f8a271e7eed965376895a5065d21fda7b7b54..5c6a4a1bc60aeeb2a4f6b374506dedc2d0c7a43b 100644 (file)
@@ -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<T1,T2,0> {
 
 template<class T1_orig, class T2_orig>
 struct promote_trait {
+
+    // Need to remove const-ness:
+    typedef typename cml::remove_const<T1_orig>::type T1_non_const;
+    typedef typename cml::remove_const<T2_orig>::type T2_non_const;
+
     // Handle promotion of small integers to int/unsigned int
-    typedef typename autopromote_trait<T1_orig>::T_numtype T1;
-    typedef typename autopromote_trait<T2_orig>::T_numtype T2;
+    typedef typename autopromote_trait<T1_non_const>::T_numtype T1;
+    typedef typename autopromote_trait<T2_non_const>::T_numtype T2;
 
     // True if T1 is higher ranked
     enum {
@@ -140,101 +142,6 @@ template<class E1, class E2> struct ScalarPromote
     typedef typename detail::promote_trait<E1,E2>::T_promote type;
 };
 
-#else
-
-namespace detail {
-
-/** @class IntPromote
- *  @brief Helper template to int-promote a type.
- */
-template<class T> struct IntPromote
-{
-    /* Signed -> signed int, unsigned -> unsigned int: */
-    typedef typename select_switch<T,
-            unsigned char,                       unsigned int,
-            unsigned short,                      unsigned int,
-            signed char,                         int,
-            char,                                int,
-            short,                               int,
-            T,                                   T
-    >::result   result;
-};
-
-} // namespace detail
-
-/** @class ScalarPromote
- *  @brief Template for compile-time type promotion via C promotion rules.
- */
-template<class E1_in, class E2_in> struct ScalarPromote
-{
-    /* Integral-promote the types (if possible). */
-    typedef typename detail::IntPromote<E1_in>::result  E1;
-    typedef typename detail::IntPromote<E2_in>::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<sizeof(long) == sizeof(unsigned int),
-            unsigned long,
-            long
-    >::result   uint_promotion;
-
-    /* Do the selection on the promoted types: */
-    typedef typename select_switch<
-        type_pair<E1,E2>,
-
-#if defined(CML_USE_LONG_DOUBLE)
-        type_pair<long double,long double>,       long double,
-        type_pair<long double,E2>,                long double,
-        type_pair<E1,long double>,                long double,
-#endif
-
-        type_pair<double,double>,                 double,
-        type_pair<double,E2>,                     double,
-        type_pair<E1,double>,                     double,
-
-        type_pair<float,float>,                   float,
-        type_pair<float,E2>,                      float,
-        type_pair<E1,float>,                      float,
-
-        type_pair<E1,E2>,                         void
-
-    >::result   float_filter;
-
-    /* The promoted integral types really matter here: */
-    typedef typename select_switch<
-        type_pair<E1,E2>,
-
-        type_pair<unsigned long,unsigned long>,   unsigned long,
-        type_pair<unsigned long,E2>,              unsigned long,
-        type_pair<E1,unsigned long>,              unsigned long,
-
-        type_pair<long,long>,                     long,
-        type_pair<long,unsigned int>,             uint_promotion,
-        type_pair<unsigned int,long>,             uint_promotion,
-
-        type_pair<long,E2>,                       long,
-        type_pair<E1,long>,                       long,
-
-        type_pair<unsigned int,unsigned int>,     unsigned int,
-        type_pair<unsigned int,E2>,               unsigned int,
-        type_pair<E1,unsigned int>,               unsigned int,
-
-        type_pair<int,int>,                       int,
-        type_pair<int,E2>,                        int,
-        type_pair<E1,int>,                        int,
-
-        type_pair<E1,E2>,                         void
-
-    >::result   int_filter;
-
-    /* Deduce the final type: */
-    typedef typename select_if<
-        same_type<float_filter,void>::is_true,
-        int_filter, float_filter>::result         type;
-};
-#endif
-
 } // namespace et
 } // namespace cml
 
This page took 0.023181 seconds and 4 git commands to generate.