Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67537 - sandbox/chrono/boost/mpl
From: vicente.botet_at_[hidden]
Date: 2011-01-01 10:12:11


Author: viboes
Date: 2011-01-01 10:12:06 EST (Sat, 01 Jan 2011)
New Revision: 67537
URL: http://svn.boost.org/trac/boost/changeset/67537

Log:
StaticInteger: added lcm.hpp and update removing eti case
Added:
   sandbox/chrono/boost/mpl/lcm.hpp (contents, props changed)
Text files modified:
   sandbox/chrono/boost/mpl/abs.hpp | 17 +++++++++--------
   sandbox/chrono/boost/mpl/gcd.hpp | 33 ++++++++++++++++++++-------------
   sandbox/chrono/boost/mpl/sign.hpp | 17 +++++++++--------
   3 files changed, 38 insertions(+), 29 deletions(-)

Modified: sandbox/chrono/boost/mpl/abs.hpp
==============================================================================
--- sandbox/chrono/boost/mpl/abs.hpp (original)
+++ sandbox/chrono/boost/mpl/abs.hpp 2011-01-01 10:12:06 EST (Sat, 01 Jan 2011)
@@ -13,7 +13,7 @@
 #define BOOST_MPL_ABS_HPP_INCLUDED
 
 #include <boost/mpl/integral_c.hpp>
-#include <boost/mpl/aux_/msvc_eti_base.hpp>
+//~ #include <boost/mpl/aux_/msvc_eti_base.hpp>
 #include <boost/mpl/aux_/na_spec.hpp>
 #include <boost/mpl/aux_/lambda_support.hpp>
 #include <boost/mpl/aux_/config/eti.hpp>
@@ -33,22 +33,23 @@
       typename BOOST_MPL_AUX_NA_PARAM(N)
>
 struct abs
-#if !defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
     : abs_impl<
           typename abs_tag<N>::type
>::template apply<N>::type
-#else
- : aux::msvc_eti_base< typename apply_wrap1<
- abs_impl< typename abs_tag<N>::type >
- , N
- >::type >::type
-#endif
 {
     BOOST_MPL_AUX_LAMBDA_SUPPORT(1, abs, (N))
 };
 
 BOOST_MPL_AUX_NA_SPEC(1, abs)
 
+template<
+ typename T
+ , T n1
+ >
+struct abs_c
+ : abs<integral_c<T,n1> >
+{
+};
 
 #if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2)
 namespace aux {

Modified: sandbox/chrono/boost/mpl/gcd.hpp
==============================================================================
--- sandbox/chrono/boost/mpl/gcd.hpp (original)
+++ sandbox/chrono/boost/mpl/gcd.hpp 2011-01-01 10:12:06 EST (Sat, 01 Jan 2011)
@@ -13,7 +13,9 @@
 #define BOOST_MPL_GCD_HPP_INCLUDED
 
 #include <boost/mpl/integral_c.hpp>
-#include <boost/mpl/aux_/msvc_eti_base.hpp>
+#include <boost/mpl/abs.hpp>
+#include <boost/mpl/aux_/largest_int.hpp>
+//~ #include <boost/mpl/aux_/msvc_eti_base.hpp>
 #include <boost/mpl/aux_/na_spec.hpp>
 #include <boost/mpl/aux_/lambda_support.hpp>
 #include <boost/mpl/aux_/config/eti.hpp>
@@ -34,37 +36,42 @@
     , typename BOOST_MPL_AUX_NA_PARAM(N2)
>
 struct gcd
-//~ #if !defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
     : gcd_impl<
           typename gcd_tag<N1>::type
         , typename gcd_tag<N2>::type
>::template apply<N1, N2>::type
-//~ #else
- //~ : aux::msvc_eti_base< typename apply_wrap1<
- //~ gcd_impl< typename gcd_tag<N1>::type >
- //~ , N1
- //~ >::type >::type
-//~ #endif
 {
     BOOST_MPL_AUX_LAMBDA_SUPPORT(2, gcd, (N1, N2))
 };
 
 BOOST_MPL_AUX_NA_SPEC(2, gcd)
 
+template<
+ typename T
+ , T n1
+ , T n2
+ >
+struct gcd_c
+ : gcd<integral_c<T,n1>,integral_c<T,n2> >
+{
+};
 
 namespace aux {
     template< typename T1, T1 n1, bool n1_is_0, typename T2, T2 n2, bool n2_is_0 >
     struct gcd_aux
  
- : gcd_aux<T2, n2, n2==0, T1, (n1 % n2), (n1 % n2)==0>
+ : gcd_aux<T2, n2, n2==0,
+ typename aux::largest_int<T1, T2>::type,
+ //~ T1,
+ (n1 % n2), (n1 % n2)==0>
     {};
     
     template <typename T1, T1 n1, typename T2, T2 n2>
- struct gcd_aux<T1, n1, false, T2, n2, true> : integral_constant<T1, n1>
+ struct gcd_aux<T1, n1, false, T2, n2, true> : integral_c<T1, n1>
     {};
 
     template <typename T1, T1 n1, typename T2, T2 n2, bool C>
- struct gcd_aux<T1, n1, true, T2, n2, C> : integral_constant<T2, n2>
+ struct gcd_aux<T1, n1, true, T2, n2, C> : integral_c<T2, n2>
     {};
 }
 
@@ -72,8 +79,8 @@
 struct gcd_impl<integral_c_tag, integral_c_tag>
 {
     template< typename N1, typename N2 > struct apply
- : aux::gcd_aux< typename N1::value_type, N1::value, N1::value==0,
- typename N2::value_type, N2::value, N2::value==0 >
+ : abs<aux::gcd_aux< typename N1::value_type, N1::value, N1::value==0,
+ typename N2::value_type, N2::value, N2::value==0 > >
     {
     };
 };

Added: sandbox/chrono/boost/mpl/lcm.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/mpl/lcm.hpp 2011-01-01 10:12:06 EST (Sat, 01 Jan 2011)
@@ -0,0 +1,90 @@
+////////////////////////////////////////////////////////////////////
+//
+// Copyright Vicente J. Botet Escriba 2010
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/mpl for documentation.
+//
+////////////////////////////////////////////////////////////////////
+#ifndef BOOST_MPL_LCM_HPP_INCLUDED
+#define BOOST_MPL_LCM_HPP_INCLUDED
+
+#include <boost/mpl/integral_c.hpp>
+#include <boost/mpl/abs.hpp>
+#include <boost/mpl/aux_/largest_int.hpp>
+//~ #include <boost/mpl/aux_/msvc_eti_base.hpp>
+#include <boost/mpl/aux_/na_spec.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/mpl/aux_/config/eti.hpp>
+#include <boost/mpl/aux_/config/integral.hpp>
+#include <boost/mpl/aux_/config/static_constant.hpp>
+
+namespace boost { namespace mpl {
+
+template< typename Tag1, typename Tag2 > struct lcm_impl;
+
+template< typename T > struct lcm_tag
+{
+ typedef typename T::tag type;
+};
+
+template<
+ typename BOOST_MPL_AUX_NA_PARAM(N1)
+ , typename BOOST_MPL_AUX_NA_PARAM(N2)
+ >
+struct lcm
+ : lcm_impl<
+ typename lcm_tag<N1>::type
+ , typename lcm_tag<N2>::type
+ >::template apply<N1, N2>::type
+{
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(2, lcm, (N1, N2))
+};
+
+BOOST_MPL_AUX_NA_SPEC(2, lcm)
+
+template<
+ typename T
+ , T n1
+ , T n2
+ >
+struct lcm_c
+ : lcm<integral_c<T,n1>,integral_c<T,n2> >
+{
+};
+
+
+namespace aux {
+ template< typename T1, T1 n1, bool n1_is_0, typename T2, T2 n2, bool n2_is_0 >
+ struct lcm_aux
+
+ : abs<integral_c< typename aux::largest_int<T1, T2>::type,
+ ( n1 / gcd<integral_c<T1,n1>, integral_c<T2,n2> >::value * n2 )
+ > >
+ {};
+
+ template <typename T1, T1 n1, typename T2, T2 n2>
+ struct lcm_aux<T1, n1, false, T2, n2, true> : integral_c<T2, 0>
+ {};
+
+ template <typename T1, T1 n1, typename T2, T2 n2, bool C>
+ struct lcm_aux<T1, n1, true, T2, n2, C> : integral_c<T1, 0>
+ {};
+}
+
+template<>
+struct lcm_impl<integral_c_tag, integral_c_tag>
+{
+ template< typename N1, typename N2 > struct apply
+ : abs<aux::lcm_aux< typename N1::value_type, N1::value, N1::value==0,
+ typename N2::value_type, N2::value, N2::value==0 > >
+ {
+ };
+};
+
+}}
+
+#endif // BOOST_MPL_LCM_HPP_INCLUDED

Modified: sandbox/chrono/boost/mpl/sign.hpp
==============================================================================
--- sandbox/chrono/boost/mpl/sign.hpp (original)
+++ sandbox/chrono/boost/mpl/sign.hpp 2011-01-01 10:12:06 EST (Sat, 01 Jan 2011)
@@ -13,7 +13,7 @@
 #define BOOST_MPL_SIGN_HPP_INCLUDED
 
 #include <boost/mpl/integral_c.hpp>
-#include <boost/mpl/aux_/msvc_eti_base.hpp>
+//~ #include <boost/mpl/aux_/msvc_eti_base.hpp>
 #include <boost/mpl/aux_/na_spec.hpp>
 #include <boost/mpl/aux_/lambda_support.hpp>
 #include <boost/mpl/aux_/config/eti.hpp>
@@ -33,22 +33,23 @@
       typename BOOST_MPL_AUX_NA_PARAM(N)
>
 struct sign
-#if !defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
     : sign_impl<
           typename sign_tag<N>::type
>::template apply<N>::type
-#else
- : aux::msvc_eti_base< typename apply_wrap1<
- sign_impl< typename sign_tag<N>::type >
- , N
- >::type >::type
-#endif
 {
     BOOST_MPL_AUX_LAMBDA_SUPPORT(1, sign, (N))
 };
 
 BOOST_MPL_AUX_NA_SPEC(1, sign)
 
+template<
+ typename T
+ , T n1
+ >
+struct sign_c
+ : sign<integral_c<T,n1> >
+{
+};
 
 #if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2)
 namespace aux {


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