Changeset 574

Show
Ignore:
Timestamp:
07/02/08 11:58:00 (5 months ago)
Author:
phill
Message:

o Now will GCC love me?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libx42pp/include/x42util.h

    r540 r574  
    3636}; 
    3737 
    38 template< typename T, size_t num_bits = sizeof( T ) * CHAR_BIT > 
     38template< typename T, size_t T_num_bits = sizeof( T ) * CHAR_BIT > 
    3939struct integer_traits 
    4040{ 
    4141private: 
    42         template< size_t num_bits
     42        template< size_t num_bits, int dummy
    4343        struct signed_max 
    4444        { 
    45                 static const T val = (T)(signed_max< num_bits - 1 >::val << 1) | 0x1; 
     45                static const T val = (T)(signed_max< num_bits - 1, dummy >::val << 1) | 0x1; 
    4646        }; 
    4747 
    48         template<
    49         struct signed_max< 2
     48        template< int dummy
     49        struct signed_max< 2, dummy
    5050        { 
    5151                static const T val = (T)0x1; 
    5252        }; 
    5353 
    54         template<
    55         struct signed_max< 1
     54        template< int dummy
     55        struct signed_max< 1, dummy
    5656        { 
    5757                //can't have a 1-bit signed value 
    5858        }; 
    5959 
    60         template<
    61         struct signed_max< 0
     60        template< int dummy
     61        struct signed_max< 0, dummy
    6262        { 
    6363                //can't have a 0-bit signed value 
    6464        }; 
    6565 
    66         template< size_t num_bits
     66        template< size_t num_bits, int dummy
    6767        struct signed_min 
    6868        { 
    69                 static const T val = (T)((signed_min< num_bits - 1 >::val) << 1); 
     69                static const T val = (T)((signed_min< num_bits - 1, dummy >::val) << 1); 
    7070        }; 
    7171 
    72         template<
    73         struct signed_min< 2
     72        template< int dummy
     73        struct signed_min< 2, dummy
    7474        { 
    7575                static const T val = (T)0x2; 
    7676        }; 
    7777 
    78         template<
    79         struct signed_min< 1
     78        template< int dummy
     79        struct signed_min< 1, dummy
    8080        { 
    8181                //can't have a 1-bit signed value 
    8282        }; 
    8383 
    84         template<
    85         struct signed_min< 0
     84        template< int dummy
     85        struct signed_min< 0, dummy
    8686        { 
    8787                //can't have a 0-bit signed value 
    8888        }; 
    8989 
    90         template< size_t num_bits
     90        template< size_t num_bits, int dummy
    9191        struct unsigned_max 
    9292        { 
    93                 static const T val = (T)(unsigned_max< num_bits - 1 >::val << 1) | 0x1; 
     93                static const T val = (T)(unsigned_max< num_bits - 1, dummy >::val << 1) | 0x1; 
    9494        }; 
    9595 
    96         template<
    97         struct unsigned_max< 1
     96        template< int dummy
     97        struct unsigned_max< 1, dummy
    9898        { 
    9999                static const T val = (T)0x1; 
    100100        }; 
    101101 
    102         template<
    103         struct unsigned_max< 0
     102        template< int dummy
     103        struct unsigned_max< 0, dummy
    104104        { 
    105105                //can'g have a 0-bit unsigned value 
     
    108108public: 
    109109        static const bool is_signed = (((T)-1) < 0); 
    110         static const T max_val = is_signed ? signed_max< num_bits >::val : unsigned_max< num_bits >::val; 
    111         static const T min_val = is_signed ? signed_min< num_bits >::val : (T)0; 
     110        static const T max_val = is_signed ? signed_max< T_num_bits, 0 >::val : unsigned_max< T_num_bits, 0 >::val; 
     111        static const T min_val = is_signed ? signed_min< T_num_bits, 0 >::val : (T)0; 
    112112 
    113         static const T bit_width = num_bits; 
     113        static const T bit_width = T_num_bits; 
    114114}; 
    115115