Boost logo

Boost-Commit :

From: steven_at_[hidden]
Date: 2008-06-25 00:06:43


Author: steven_watanabe
Date: 2008-06-25 00:06:43 EDT (Wed, 25 Jun 2008)
New Revision: 46674
URL: http://svn.boost.org/trac/boost/changeset/46674

Log:
Inline do_call_base_unit_converter_impl and make it always go to the same implementation so that I don't need base_unit_converter::is_defined. Altogether this saves 1000 template instantiations out of 25000 for systems.cpp
Text files modified:
   trunk/boost/units/detail/conversion_impl.hpp | 59 ++++++++++++++-------------------------
   1 files changed, 21 insertions(+), 38 deletions(-)

Modified: trunk/boost/units/detail/conversion_impl.hpp
==============================================================================
--- trunk/boost/units/detail/conversion_impl.hpp (original)
+++ trunk/boost/units/detail/conversion_impl.hpp 2008-06-25 00:06:43 EDT (Wed, 25 Jun 2008)
@@ -123,42 +123,22 @@
 
 namespace detail {
 
-template<bool is_defined>
-struct do_call_base_unit_converter_impl;
-
-template<>
-struct do_call_base_unit_converter_impl<true>
-{
- template<class Source, class Dest>
- struct apply : base_unit_converter<Source, Dest> { };
-};
-
-template<>
-struct do_call_base_unit_converter_impl<false>
-{
- template<class Source, class Dest>
- struct apply {
- typedef select_base_unit_converter<typename unscale<Source>::type, typename unscale<Dest>::type> selector;
- typedef typename selector::source_type source_type;
- typedef typename selector::destination_type destination_type;
- typedef base_unit_converter<source_type, destination_type> converter;
- typedef typename mpl::divides<typename get_scale_list<Source>::type, typename get_scale_list<source_type>::type>::type source_factor;
- typedef typename mpl::divides<typename get_scale_list<Dest>::type, typename get_scale_list<destination_type>::type>::type destination_factor;
- typedef typename mpl::divides<source_factor, destination_factor>::type factor;
- typedef eval_scale_list<factor> eval_factor;
- typedef typename multiply_typeof_helper<typename converter::type, typename eval_factor::type>::type type;
- static type value()
- {
- return(converter::value() * eval_factor::value());
- }
- };
-};
-
 template<class Source, class Dest>
-struct do_call_base_unit_converter :
- do_call_base_unit_converter_impl<
- base_unit_converter<Source, Dest>::is_defined
- >::template apply<Source, Dest> {};
+struct do_call_base_unit_converter {
+ typedef select_base_unit_converter<typename unscale<Source>::type, typename unscale<Dest>::type> selector;
+ typedef typename selector::source_type source_type;
+ typedef typename selector::destination_type destination_type;
+ typedef base_unit_converter<source_type, destination_type> converter;
+ typedef typename mpl::divides<typename get_scale_list<Source>::type, typename get_scale_list<source_type>::type>::type source_factor;
+ typedef typename mpl::divides<typename get_scale_list<Dest>::type, typename get_scale_list<destination_type>::type>::type destination_factor;
+ typedef typename mpl::divides<source_factor, destination_factor>::type factor;
+ typedef eval_scale_list<factor> eval_factor;
+ typedef typename multiply_typeof_helper<typename converter::type, typename eval_factor::type>::type type;
+ static type value()
+ {
+ return(converter::value() * eval_factor::value());
+ }
+};
 
 template<bool forward_is_defined, bool reverse_is_defined>
 struct call_base_unit_converter_base_unit_impl;
@@ -167,7 +147,8 @@
 struct call_base_unit_converter_base_unit_impl<true, true>
 {
     template<class Source, class Dest>
- struct apply : do_call_base_unit_converter<Source, typename Dest::unit_type>
+ struct apply
+ : do_call_base_unit_converter<Source, typename Dest::unit_type>
     {
     };
 };
@@ -176,7 +157,8 @@
 struct call_base_unit_converter_base_unit_impl<true, false>
 {
     template<class Source, class Dest>
- struct apply : do_call_base_unit_converter<Source, typename Dest::unit_type>
+ struct apply
+ : do_call_base_unit_converter<Source, typename Dest::unit_type>
     {
     };
 };
@@ -263,7 +245,8 @@
 struct call_base_unit_converter_impl<true>
 {
     template<class Source, class Dest>
- struct apply : do_call_base_unit_converter<Source, Dest>
+ struct apply
+ : do_call_base_unit_converter<Source, Dest>
     {
     };
 };


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