Ticket #5214: boost-chrono-vc9-conversion.patch

File boost-chrono-vc9-conversion.patch, 7.0 KB (added by David Deakins, 12 years ago)

Patch for enable_if expression adjustment

  • detail/inlined/win/chrono.hpp

     
    5252                        "chrono::steady_clock" ));
    5353    }
    5454
    55 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1500)
    56     // trying to simplify expression (Pb. with MSVC.9.0)
    57     steady_clock::rep r = static_cast<steady_clock::rep>((nanosecs_per_tic) * pcount.QuadPart);
    58     steady_clock::duration d(r);
    59     return steady_clock::time_point(d);
    60 #else
    6155    return steady_clock::time_point(steady_clock::duration(
    6256      static_cast<steady_clock::rep>((nanosecs_per_tic) * pcount.QuadPart)));
    63 #endif
    6457  }
    6558
    6659
  • detail/is_evenly_divisible_by.hpp

     
     1//  is_evenly_divisible_by.hpp  --------------------------------------------------------------//
     2
     3//  Copyright 2009-2010 Vicente J. Botet Escriba
     4
     5//  Distributed under the Boost Software License, Version 1.0.
     6//  See http://www.boost.org/LICENSE_1_0.txt
     7
     8#ifndef BOOST_CHRONO_DETAIL_IS_EVENLY_DIVISIBLE_BY_HPP
     9#define BOOST_CHRONO_DETAIL_IS_EVENLY_DIVISIBLE_BY_HPP
     10
     11#include <boost/chrono/config.hpp>
     12
     13#include <boost/mpl/logical.hpp>
     14#include <boost/ratio/ratio.hpp>
     15
     16
     17namespace boost {
     18namespace chrono {
     19namespace chrono_detail {
     20
     21  template <class R1, class R2>
     22  struct is_evenly_divisible_by : public boost::mpl::bool_ < ratio_divide<R1, R2>::type::den == 1 >
     23  {};
     24
     25} // namespace chrono_detail
     26} // namespace detail
     27} // namespace chrono
     28
     29#endif // BOOST_CHRONO_DETAIL_IS_EVENLY_DIVISIBLE_BY_HPP
  • duration.hpp

     
    4343#include <boost/type_traits/is_convertible.hpp>
    4444#include <boost/type_traits/is_floating_point.hpp>
    4545#include <boost/type_traits/is_unsigned.hpp>
     46#include <boost/chrono/detail/is_evenly_divisible_by.hpp>
    4647
    4748#include <boost/cstdint.hpp>
    4849#include <boost/utility/enable_if.hpp>
     
    432433        template <class Rep2>
    433434        BOOST_CHRONO_CONSTEXPR
    434435        explicit duration(const Rep2& r
    435 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1500)
    436 #else
    437436        , typename boost::enable_if <
    438437                    mpl::and_ <
    439438                        boost::is_convertible<Rep2, rep>,
     
    446445                        >
    447446                    >
    448447                >::type* = 0
    449 #endif   
    450     )
     448                )
    451449                  : rep_(r) { }
    452450        ~duration() {} //= default;
    453451        duration(const duration& rhs) : rep_(rhs.rep_) {} // = default;
     
    461459        template <class Rep2, class Period2>
    462460        BOOST_CHRONO_CONSTEXPR
    463461        duration(const duration<Rep2, Period2>& d
    464 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1500)
    465 #else
    466462        , typename boost::enable_if <
    467463                    mpl::or_ <
    468464                        treat_as_floating_point<rep>,
    469465                        mpl::and_ <
    470                             mpl::bool_ < ratio_divide<Period2, period>::type::den == 1>,
     466                            chrono_detail::is_evenly_divisible_by<Period2, period>,
    471467                            mpl::not_ < treat_as_floating_point<Rep2> >
    472468                        >
    473469                    >
    474470                >::type* = 0
    475 #endif   
    476     )
     471        )
    477472            : rep_(chrono::detail::duration_cast<duration<Rep2, Period2>, duration>()(d).count()) {}
    478473
    479474        // observer
     
    560555
    561556    template <class Rep1, class Period, class Rep2>
    562557    inline
    563 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1500)
    564     duration<typename common_type<Rep1, Rep2>::type, Period>   
    565 #else
    566558    typename boost::enable_if <
    567559        mpl::and_ <
    568560        boost::is_convertible<Rep1, typename common_type<Rep1, Rep2>::type>,
     
    570562        >,
    571563        duration<typename common_type<Rep1, Rep2>::type, Period>
    572564    >::type
    573 #endif   
    574565    operator*(const duration<Rep1, Period>& d, const Rep2& s)
    575566    {
    576567        typedef typename common_type<Rep1, Rep2>::type CR;
     
    581572
    582573    template <class Rep1, class Period, class Rep2>
    583574    inline
    584 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1500)
    585         duration<typename common_type<Rep1, Rep2>::type, Period>
    586 #else
    587575    typename boost::enable_if <
    588576        mpl::and_ <
    589577        boost::is_convertible<Rep1, typename common_type<Rep1, Rep2>::type>,
     
    591579        >,
    592580        duration<typename common_type<Rep1, Rep2>::type, Period>
    593581    >::type
    594 #endif
    595582    operator*(const Rep1& s, const duration<Rep2, Period>& d)
    596583    {
    597584        return d * s;
     
    676663        bool operator()(const LhsDuration& lhs, const RhsDuration& rhs)
    677664        {
    678665            typedef typename common_type<LhsDuration, RhsDuration>::type CD;
    679 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1500)
    680             // trying to simplify expression so enable_if is not used (Pb. with MSVC.9.0)
    681             return
    682                 chrono::detail::duration_cast<LhsDuration, CD>()(lhs).count()
    683             ==
    684                 chrono::detail::duration_cast<RhsDuration, CD>()(rhs).count();
    685 #else
    686666            return CD(lhs).count() == CD(rhs).count();
    687 #endif
    688667        }
    689668    };
    690669
     
    703682        bool operator()(const LhsDuration& lhs, const RhsDuration& rhs)
    704683        {
    705684            typedef typename common_type<LhsDuration, RhsDuration>::type CD;
    706 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1500)
    707             // trying to simplify expression so enable_if is not used (Pb. with MSVC.9.0)
    708             return
    709                 chrono::detail::duration_cast<LhsDuration, CD>()(lhs).count()
    710             <
    711                 chrono::detail::duration_cast<RhsDuration, CD>()(rhs).count();
    712 #else
    713685            return CD(lhs).count() < CD(rhs).count();
    714 #endif           
    715686        }
    716687    };
    717688
     
    801772    // Compile-time select the most efficient algorithm for the conversion...
    802773    template <class ToDuration, class Rep, class Period>
    803774    inline BOOST_CHRONO_CONSTEXPR
    804 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1500)
    805     ToDuration
    806 #else
    807775    typename boost::enable_if <
    808776      boost::chrono::detail::is_duration<ToDuration>, ToDuration>::type
    809 #endif   
    810777    duration_cast(const duration<Rep, Period>& fd)
    811778    {
    812779        return boost::chrono::detail::duration_cast<
  • time_point.hpp

     
    170170        template <class Duration2>
    171171        BOOST_CHRONO_CONSTEXPR
    172172        time_point(const time_point<clock, Duration2>& t
    173 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1500)
    174 #else
    175173                , typename boost::enable_if
    176174                <
    177175                    boost::is_convertible<Duration2, duration>
    178176                >::type* = 0
    179 #endif
    180177        )
    181178            : d_(t.time_since_epoch())
    182179        {