Boost logo

Boost :

From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2002-07-17 01:45:52


Hi,

I propose change cast.hpp (see diff below). In one statement I propose to change implementation of numeric_min_selector to use select_type facility. Advantages:
1. Elegance: we reusing existent select_type facility instead of reimplementing it again.
2. Simplicity: it became more obvious what is going on; we don't need to introduce nee member template classes.
3. Consiseess: it became shorter; we don't need one of two auxiliary structures.
4. We don't probably need hack for GCC implemented there any more (though it should be rechecked)
5. It will also compile with sunpro 6.1 (with STLPort) now.

What you think?

Gennadiy.

Index: cast.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/cast.hpp,v
retrieving revision 1.14
diff -c -r1.14 cast.hpp
*** cast.hpp 30 Jan 2002 20:02:11 -0000 1.14
--- cast.hpp 17 Jul 2002 06:32:36 -0000
***************
*** 48,53 ****
--- 48,54 ----
  # include <typeinfo>
  # include <boost/type.hpp>
  # include <boost/limits.hpp>
+ # include <boost/detail/select_type.hpp>

  // It has been demonstrated numerous times that MSVC 6.0 fails silently at link
  // time if you use a template function which has template parameters that don't
***************
*** 125,176 ****

      namespace detail
      {
! template <bool is_signed> struct numeric_min_select;
!
! template<>
! struct numeric_min_select<true>
! {
! template <class T>
! struct limits : std::numeric_limits<T>
! {
           static inline T min()
! # ifndef __GNUC__ // bug workaround courtesy Jens Maurer
! {
! return std::numeric_limits<T>::min() >= 0
                       // unary minus causes integral promotion, thus the static_cast<>
                       ? static_cast<T>(-std::numeric_limits<T>::max())
                       : std::numeric_limits<T>::min();
- }
- # else
- ;
- # endif
           };
- };
-
- # ifdef __GNUC__ // bug workaround courtesy Jens Maurer
- template<> template<class T>
- inline T numeric_min_select<true>::limits<T>::min()
- {
- return std::numeric_limits<T>::min() >= 0
- // unary minus causes integral promotion, thus the static_cast<>
- ? static_cast<T>(-std::numeric_limits<T>::max())
- : std::numeric_limits<T>::min();
- }
- # endif
-
- template<>
- struct numeric_min_select<false>
- {
- template <class T>
- struct limits : std::numeric_limits<T> {};
        };
!
        // Move to namespace boost in utility.hpp?
        template <class T>
        struct fixed_numeric_limits
! : public numeric_min_select<
! std::numeric_limits<T>::is_signed
! >::template limits<T>
        {
        };
      } // namespace detail
--- 126,150 ----

      namespace detail
      {
! template <class T>
! struct signed_numeric_limits : std::numeric_limits<T>
! {
           static inline T min()
! {
! return std::numeric_limits<T>::min() >= 0
                       // unary minus causes integral promotion, thus the static_cast<>
                       ? static_cast<T>(-std::numeric_limits<T>::max())
                       : std::numeric_limits<T>::min();
           };
        };
!
        // Move to namespace boost in utility.hpp?
        template <class T>
        struct fixed_numeric_limits
! : public if_true< std::numeric_limits<T>::is_signed >
! ::template then< signed_numeric_limits<T>,
! std::numeric_limits<T>
! >::type
        {
        };
      } // namespace detail

_____________________________________________________________
A free email account your friends will never forget!
Get YOURNAME_at_[hidden] at http://www.emailaccount.com/

_____________________________________________________________
Promote your group and strengthen ties to your members with email_at_[hidden] by Everyone.net http://www.everyone.net/?btn=tag


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk