|
Boost-Commit : |
From: hinnant_at_[hidden]
Date: 2007-12-30 15:15:59
Author: hinnant
Date: 2007-12-30 15:15:59 EST (Sun, 30 Dec 2007)
New Revision: 42377
URL: http://svn.boost.org/trac/boost/changeset/42377
Log:
Slight optimization on op== and op< in <hdate_time>.
Text files modified:
sandbox/committee/LWG/ref_impl/hdate_time | 109 +++++++++++++++++++++++----------------
1 files changed, 64 insertions(+), 45 deletions(-)
Modified: sandbox/committee/LWG/ref_impl/hdate_time
==============================================================================
--- sandbox/committee/LWG/ref_impl/hdate_time (original)
+++ sandbox/committee/LWG/ref_impl/hdate_time 2007-12-30 15:15:59 EST (Sun, 30 Dec 2007)
@@ -600,39 +600,48 @@
// Duration ==
+template <class LhsDuration, class RhsDuration,
+ bool = __is_duration_exactly_convertible<RhsDuration, LhsDuration>::value,
+ bool = __is_duration_exactly_convertible<LhsDuration, RhsDuration>::value>
+struct __duration_eq;
+
+template <class LhsDuration>
+struct __duration_eq<LhsDuration, LhsDuration, true, true>
+{
+ bool operator()(const LhsDuration& lhs, const LhsDuration& rhs)
+ {return lhs.count() == rhs.count();}
+};
+
template <class LhsDuration, class RhsDuration>
-inline
-bool
-__duration_eq(const LhsDuration& lhs, const RhsDuration& rhs, false_type, false_type)
+struct __duration_eq<LhsDuration, RhsDuration, true, true>
{
- typedef typename __make_duration<LhsDuration, RhsDuration>::type CommonDuration;
- return CommonDuration(lhs).count() == CommonDuration(rhs).count();
-}
+ bool operator()(const LhsDuration& lhs, const RhsDuration& rhs)
+ {return lhs.count() == LhsDuration(rhs).count();}
+};
template <class LhsDuration, class RhsDuration>
-inline
-bool
-__duration_eq(const LhsDuration& lhs, const RhsDuration& rhs, false_type, true_type)
+struct __duration_eq<LhsDuration, RhsDuration, true, false>
{
- return RhsDuration(lhs).count() == rhs.count();
-}
+ bool operator()(const LhsDuration& lhs, const RhsDuration& rhs)
+ {return lhs.count() == LhsDuration(rhs).count();}
+};
template <class LhsDuration, class RhsDuration>
-inline
-bool
-__duration_eq(const LhsDuration& lhs, const RhsDuration& rhs, false_type)
+struct __duration_eq<LhsDuration, RhsDuration, false, true>
{
- return __duration_eq(lhs, rhs, false_type(),
- integral_constant<bool, __is_duration_exactly_convertible<LhsDuration, RhsDuration>::value>());
-}
+ bool operator()(const LhsDuration& lhs, const RhsDuration& rhs)
+ {return RhsDuration(lhs).count() == rhs.count();}
+};
template <class LhsDuration, class RhsDuration>
-inline
-bool
-__duration_eq(const LhsDuration& lhs, const RhsDuration& rhs, true_type)
+struct __duration_eq<LhsDuration, RhsDuration, false, false>
{
- return lhs.count() == LhsDuration(rhs).count();
-}
+ bool operator()(const LhsDuration& lhs, const RhsDuration& rhs)
+ {
+ typedef typename __make_duration<LhsDuration, RhsDuration>::type CommonDuration;
+ return CommonDuration(lhs).count() == CommonDuration(rhs).count();
+ }
+};
template <class LhsDuration, class RhsDuration>
inline
@@ -644,7 +653,7 @@
>::type
operator==(const LhsDuration& lhs, const RhsDuration& rhs)
{
- return __duration_eq(lhs, rhs, integral_constant<bool, __is_duration_exactly_convertible<RhsDuration, LhsDuration>::value>());
+ return __duration_eq<LhsDuration, RhsDuration>()(lhs, rhs);
}
// Duration !=
@@ -664,38 +673,48 @@
// Duration <
+template <class LhsDuration, class RhsDuration,
+ bool = __is_duration_exactly_convertible<RhsDuration, LhsDuration>::value,
+ bool = __is_duration_exactly_convertible<LhsDuration, RhsDuration>::value>
+struct __duration_lt;
+
+template <class LhsDuration>
+struct __duration_lt<LhsDuration, LhsDuration, true, true>
+{
+ bool operator()(const LhsDuration& lhs, const LhsDuration& rhs)
+ {return lhs.count() < rhs.count();}
+};
+
template <class LhsDuration, class RhsDuration>
-inline
-bool
-__duration_lt(const LhsDuration& lhs, const RhsDuration& rhs, false_type, false_type)
+struct __duration_lt<LhsDuration, RhsDuration, true, true>
{
- typedef typename __make_duration<LhsDuration, RhsDuration>::type CommonDuration;
- return CommonDuration(lhs).count() < CommonDuration(rhs).count();
-}
+ bool operator()(const LhsDuration& lhs, const RhsDuration& rhs)
+ {return lhs.count() < LhsDuration(rhs).count();}
+};
template <class LhsDuration, class RhsDuration>
-inline
-bool
-__duration_lt(const LhsDuration& lhs, const RhsDuration& rhs, false_type, true_type)
+struct __duration_lt<LhsDuration, RhsDuration, true, false>
{
- return RhsDuration(lhs).count() < rhs.count();
-}
+ bool operator()(const LhsDuration& lhs, const RhsDuration& rhs)
+ {return lhs.count() < LhsDuration(rhs).count();}
+};
template <class LhsDuration, class RhsDuration>
-inline
-bool
-__duration_lt(const LhsDuration& lhs, const RhsDuration& rhs, false_type)
+struct __duration_lt<LhsDuration, RhsDuration, false, true>
{
- return __duration_lt(lhs, rhs, false_type(), integral_constant<bool, __is_duration_exactly_convertible<LhsDuration, RhsDuration>::value>());
-}
+ bool operator()(const LhsDuration& lhs, const RhsDuration& rhs)
+ {return RhsDuration(lhs).count() < rhs.count();}
+};
template <class LhsDuration, class RhsDuration>
-inline
-bool
-__duration_lt(const LhsDuration& lhs, const RhsDuration& rhs, true_type)
+struct __duration_lt<LhsDuration, RhsDuration, false, false>
{
- return lhs.count() < LhsDuration(rhs).count();
-}
+ bool operator()(const LhsDuration& lhs, const RhsDuration& rhs)
+ {
+ typedef typename __make_duration<LhsDuration, RhsDuration>::type CommonDuration;
+ return CommonDuration(lhs).count() < CommonDuration(rhs).count();
+ }
+};
template <class LhsDuration, class RhsDuration>
inline
@@ -707,7 +726,7 @@
>::type
operator< (const LhsDuration& lhs, const RhsDuration& rhs)
{
- return __duration_lt(lhs, rhs, integral_constant<bool, __is_duration_exactly_convertible<RhsDuration, LhsDuration>::value>());
+ return __duration_lt<LhsDuration, RhsDuration>()(lhs, rhs);
}
// Duration >
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk