Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63659 - in sandbox/SOC/2010/bits_and_ints: boost/integer libs/integer/test
From: muriloufg_at_[hidden]
Date: 2010-07-05 11:47:19


Author: murilov
Date: 2010-07-05 11:47:17 EDT (Mon, 05 Jul 2010)
New Revision: 63659
URL: http://svn.boost.org/trac/boost/changeset/63659

Log:
Added static_abs.hpp file wich defines static_abs<> and mpl::abs<> metafunctions
Added static_gcd.hpp wich defines mpl::gcd<> metafunction
Added static_lcm.hpp wich defines mpl::lcm<> metafunction
Added static_sign.hpp wich defines static_sign<> and mpl::sign<> metafunctions
Added tests: static_gcd_test.cpp, static_lcm_test.cpp, static_abs_test.cpp and added tests in sign_test.cpp
Added:
   sandbox/SOC/2010/bits_and_ints/boost/integer/is_integral_constant.hpp (contents, props changed)
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_abs.hpp (contents, props changed)
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_gcd.hpp (contents, props changed)
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_lcm.hpp (contents, props changed)
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign.hpp (contents, props changed)
   sandbox/SOC/2010/bits_and_ints/libs/integer/test/static_abs_test.cpp (contents, props changed)
   sandbox/SOC/2010/bits_and_ints/libs/integer/test/static_gcd_test.cpp (contents, props changed)
   sandbox/SOC/2010/bits_and_ints/libs/integer/test/static_lcm_test.cpp (contents, props changed)
Text files modified:
   sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp | 5 +++++
   sandbox/SOC/2010/bits_and_ints/boost/integer/pop_count.hpp | 25 +++++++++----------------
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_same_sign.hpp | 7 ++++++-
   sandbox/SOC/2010/bits_and_ints/libs/integer/test/Jamfile.v2 | 3 +++
   sandbox/SOC/2010/bits_and_ints/libs/integer/test/sign_test.cpp | 28 ++++++++++++++++++++++++++++
   5 files changed, 51 insertions(+), 17 deletions(-)

Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp 2010-07-05 11:47:17 EDT (Mon, 05 Jul 2010)
@@ -18,6 +18,7 @@
 #include <boost/integer/bit_reversal.hpp>
 #include <boost/integer/static_bit_reversal.hpp>
 #include <boost/integer/sign.hpp>
+#include <boost/integer/static_sign.hpp>
 #include <boost/integer/same_sign.hpp>
 #include <boost/integer/static_same_sign.hpp>
 #include <boost/integer/pop_count.hpp>
@@ -27,5 +28,9 @@
 #include <boost/integer/swap.hpp>
 #include <boost/integer/safe_avg.hpp>
 #include <boost/integer/round_power_2.hpp>
+#include <boost/integer/is_integral_constant.hpp>
+#include <boost/integer/static_abs.hpp>
+#include <boost/integer/static_gcd.hpp>
+#include <boost/integer/static_lcm.hpp>
 
 #endif
\ No newline at end of file

Added: sandbox/SOC/2010/bits_and_ints/boost/integer/is_integral_constant.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/is_integral_constant.hpp 2010-07-05 11:47:17 EDT (Mon, 05 Jul 2010)
@@ -0,0 +1,49 @@
+// Boost integer/is_integral_constant.hpp header file ------------------------------//
+
+// (C) Copyright Murilo Adriano Vasconcelos 2010.
+// (C) Copyright Vicente J. Botet Escribá 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 for updates, documentation, and revision history.
+
+#ifndef BOOST_STATIC_IS_INTEGRAL_CONSTANT_INCLUDED
+#define BOOST_STATIC_IS_INTEGRAL_CONSTANT_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/integral_c.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+#include <boost/type_traits/is_integral.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+namespace boost {
+
+/*
+ * is_integral_constant<T> checks if T is or not an integral_constant
+ */
+
+namespace mpl {
+
+BOOST_MPL_HAS_XXX_TRAIT_DEF(tag)
+BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type)
+BOOST_MPL_HAS_XXX_TRAIT_DEF(value)
+BOOST_MPL_HAS_XXX_TRAIT_DEF(type)
+
+template <typename IC>
+struct is_integral_constant : and_<
+ and_< has_tag<IC>, is_same<typename IC::tag, integral_c_tag> >,
+ and_< has_value_type<IC>, is_integral<typename IC::value_type> >,
+ //has_value<IC>,
+ has_type<IC>,
+ true_
+ >
+{};
+
+}
+
+
+} // boost
+
+#endif
\ No newline at end of file

Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/pop_count.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/pop_count.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/pop_count.hpp 2010-07-05 11:47:17 EDT (Mon, 05 Jul 2010)
@@ -11,6 +11,7 @@
 #define BOOST_POP_COUNT_INCLUDED
 
 #include <boost/cstdint.hpp>
+#include <boost/integer/detail/pop_count.hpp>
 
 /*
  * Population count (pop_count) counts the number of 1-bits in an
@@ -27,23 +28,15 @@
 namespace boost {
 
 int pop_count(uintmax_t value)
-{
- static const uintmax_t mask[6] = {
+{
+ using integer_detail::pop_count_mask;
+ value = (value & pop_count_mask[0]) + ((value >> 1) & pop_count_mask[0]);
+ value = (value & pop_count_mask[1]) + ((value >> 2) & pop_count_mask[1]);
+ value = (value & pop_count_mask[2]) + ((value >> 4) & pop_count_mask[2]);
+ value = (value & pop_count_mask[3]) + ((value >> 8) & pop_count_mask[3]);
+ value = (value & pop_count_mask[4]) + ((value >> 16) & pop_count_mask[4]);
 #ifndef BOOST_NO_INT64_T
- 0x5555555555555555, 0x3333333333333333, 0x0F0F0F0F0F0F0F0F,
- 0x00FF00FF00FF00FF, 0x0000FFFF0000FFFF, 0x00000000FFFFFFFF
-#else
- 0x55555555, 0x33333333, 0x0F0F0F0F, 0x00FF00FF, 0x0000FFFF, 0x0
-#endif
- };
-
- value = (value & mask[0]) + ((value >> 1) & mask[0]);
- value = (value & mask[1]) + ((value >> 2) & mask[1]);
- value = (value & mask[2]) + ((value >> 4) & mask[2]);
- value = (value & mask[3]) + ((value >> 8) & mask[3]);
- value = (value & mask[4]) + ((value >> 16) & mask[4]);
-#ifndef BOOST_NO_INT64_T
- value = (value & mask[5]) + ((value >> 32) & mask[5]);
+ value = (value & pop_count_mask[5]) + ((value >> 32) & pop_count_mask[5]);
 #endif
         
         return int(value);

Added: sandbox/SOC/2010/bits_and_ints/boost/integer/static_abs.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_abs.hpp 2010-07-05 11:47:17 EDT (Mon, 05 Jul 2010)
@@ -0,0 +1,46 @@
+// Boost integer/static_abs.hpp header file ------------------------------//
+
+// (C) Copyright Murilo Adriano Vasconcelos 2010.
+// (C) Copyright Vicente J. Botet Escribá 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 for updates, documentation, and revision history.
+
+#ifndef BOOST_STATIC_ABS_INCLUDED
+#define BOOST_STATIC_ABS_INCLUDED
+
+#include <boost/utility/enable_if.hpp>
+#include <boost/integer/is_integral_constant.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/integral_c.hpp>
+#include <boost/type_traits/is_unsigned.hpp>
+#include <boost/type_traits/make_unsigned.hpp>
+
+namespace boost
+{
+
+/*
+ * This header defines mpl::abs<> and static_abs<> metafunctions.
+ * The mpl::abs<> version returns the absolute value of an mpl::integral_c<>
+ * and the static_abs version returns the absolute value from an integral value.
+ */
+
+namespace mpl {
+
+template <typename IC, class Enable = typename enable_if< is_integral_constant<IC> >::type>
+struct abs : mpl::integral_c<typename make_unsigned<typename IC::value_type>::type,
+ (IC::value < 0 ? -IC::value : IC::value)
+>
+{};
+
+}
+
+template <typename T, T data, class Enable = typename enable_if< is_integral<T> >::type >
+struct static_abs : mpl::abs< mpl::integral_c<T, data> >
+{};
+
+} // boost
+
+#endif
\ No newline at end of file

Added: sandbox/SOC/2010/bits_and_ints/boost/integer/static_gcd.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_gcd.hpp 2010-07-05 11:47:17 EDT (Mon, 05 Jul 2010)
@@ -0,0 +1,51 @@
+// Boost integer/static_gcd.hpp header file ------------------------------//
+
+// (C) Copyright Murilo Adriano Vasconcelos 2010.
+// (C) Copyright Vicente J. Botet Escribá 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 for updates, documentation, and revision history.
+
+#ifndef BOOST_STATIC_GCD_INCLUDED
+#define BOOST_STATIC_GCD_INCLUDED
+
+#include <boost/utility/enable_if.hpp>
+#include <boost/integer/static_abs.hpp>
+#include <boost/integer/is_integral_constant.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/integral_c.hpp>
+#include <boost/math/common_factor_ct.hpp>
+
+namespace boost {
+
+/*
+ * This header defines mpl::gcd<> metafunction wich calculates
+ * the greatest common divisor of two given mpl::integral_c<>
+ * ICT1 and ICT2.
+ */
+
+namespace mpl {
+
+template <typename ICT1, typename ICT2
+ , class Enable = typename enable_if<
+ and_<
+ is_integral_constant<ICT1>,
+ is_integral_constant<ICT2>
+ >
+ >::type
+>
+struct gcd : integral_c<uintmax_t,
+ math::static_gcd<
+ mpl::abs<ICT1>::value,
+ mpl::abs<ICT2>::value
+ >::value
+>
+{};
+
+}
+
+} // boost
+
+#endif
\ No newline at end of file

Added: sandbox/SOC/2010/bits_and_ints/boost/integer/static_lcm.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_lcm.hpp 2010-07-05 11:47:17 EDT (Mon, 05 Jul 2010)
@@ -0,0 +1,50 @@
+// Boost integer/static_lcm.hpp header file ------------------------------//
+
+// (C) Copyright Murilo Adriano Vasconcelos 2010.
+// (C) Copyright Vicente J. Botet Escribá 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 for updates, documentation, and revision history.
+
+#ifndef BOOST_STATIC_LCM_INCLUDED
+#define BOOST_STATIC_LCM_INCLUDED
+
+#include <boost/utility/enable_if.hpp>
+#include <boost/integer/is_integral_constant.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/integral_c.hpp>
+#include <boost/math/common_factor_ct.hpp>
+
+namespace boost {
+
+/*
+ * This header defines mpl::lcm<> metafunction wich calculates the
+ * least common multiplier from two given mpl::integral_c<> ICT1 and ICT2.
+ */
+
+namespace mpl {
+
+template <typename ICT1, typename ICT2
+ , class Enable = typename enable_if<
+ and_<
+ is_integral_constant<ICT1>,
+ is_integral_constant<ICT2>
+ >
+ >::type
+>
+struct lcm : integral_c<uintmax_t,
+ math::static_lcm<
+ abs<ICT1>::value,
+ abs<ICT2>::value
+ >::value
+>
+{};
+
+}
+
+
+} // boost
+
+#endif
\ No newline at end of file

Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/static_same_sign.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/static_same_sign.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_same_sign.hpp 2010-07-05 11:47:17 EDT (Mon, 05 Jul 2010)
@@ -7,6 +7,9 @@
 
 // See http://www.boost.org for updates, documentation, and revision history.
 
+#ifndef BOOST_STATIC_SAME_SIGN_INCLUDED
+#define BOOST_STATIC_SAME_SIGN_INCLUDED
+
 #include <boost/mpl/integral_c.hpp>
 #include <boost/mpl/bool.hpp>
 #include <boost/type_traits/is_integral.hpp>
@@ -49,4 +52,6 @@
 struct static_same_sign : mpl::same_sign< mpl::integral_c<T, first>, mpl::integral_c<T, second> >
 {};
 
-}
\ No newline at end of file
+}
+
+#endif
\ No newline at end of file

Added: sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign.hpp 2010-07-05 11:47:17 EDT (Mon, 05 Jul 2010)
@@ -0,0 +1,55 @@
+// Boost integer/static_sign.hpp header file ------------------------------//
+
+// (C) Copyright Murilo Adriano Vasconcelos 2010.
+// (C) Copyright Vicente J. Botst 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 for updates, documentation, and revision history.
+
+#ifndef BOOST_STATIC_SIGN_INCLUDED
+#define BOOST_STATIC_SIGN_INCLUDED
+
+#include <boost/utility/enable_if.hpp>
+#include <boost/integer/is_integral_constant.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/integral_c.hpp>
+#include <boost/type_traits/is_unsigned.hpp>
+#include <boost/type_traits/make_signed.hpp>
+
+namespace boost {
+
+/*
+ * This header defines mpl::sign<> and static_sign<> metafunctions.
+ */
+
+namespace mpl {
+
+template <typename IC
+ , class Enable = typename enable_if<
+ is_integral_constant<IC>
+ >::type
+>
+struct sign :
+ integral_c<
+ typename make_signed<
+ typename IC::value_type
+ >::type,
+ (IC::value == 0 ? 0 : (IC::value < 0 ? -1 : 1))
+ >
+{};
+
+}
+
+template <typename T, T data
+ , class Enable = typename enable_if<
+ is_integral<T>
+ >::type
+>
+struct static_sign : mpl::sign<mpl::integral_c< T, data> >
+{};
+
+} // boost
+
+#endif
\ No newline at end of file

Modified: sandbox/SOC/2010/bits_and_ints/libs/integer/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/libs/integer/test/Jamfile.v2 (original)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/test/Jamfile.v2 2010-07-05 11:47:17 EDT (Mon, 05 Jul 2010)
@@ -18,6 +18,9 @@
                 [ run sign_extend_test.cpp ]
                 [ run bit_reversal_test.cpp ]
                 [ run sign_test.cpp ]
+ [ run static_abs_test.cpp ]
+ [ run static_gcd_test.cpp ]
+ [ run static_lcm_test.cpp ]
         [ compile cstdint_include_test.cpp ]
         [ compile integer_traits_include_test.cpp ]
         [ compile integer_include_test.cpp ]

Modified: sandbox/SOC/2010/bits_and_ints/libs/integer/test/sign_test.cpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/libs/integer/test/sign_test.cpp (original)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/test/sign_test.cpp 2010-07-05 11:47:17 EDT (Mon, 05 Jul 2010)
@@ -14,6 +14,9 @@
 #define SIGN_TEST(n, m) \
 BOOST_TEST(::boost::sign(n) == m)
 
+#define STATIC_SIGN_TEST(t, v, e) \
+BOOST_TEST((::boost::static_sign<t, v>::value == e))
+
 
 // Main testing function
 int main(int, char* [])
@@ -37,9 +40,34 @@
         
         SIGN_TEST(unsigned(0), 0);
         
+
+ STATIC_SIGN_TEST(int, -1, -1);
+ STATIC_SIGN_TEST(int, -10, -1);
+ STATIC_SIGN_TEST(int, -123123, -1);
+ STATIC_SIGN_TEST(int, 1, 1);
+ STATIC_SIGN_TEST(int, 10, 1);
+ STATIC_SIGN_TEST(int, 123123, 1);
+ STATIC_SIGN_TEST(int, 0, 0);
+ STATIC_SIGN_TEST(int, -1000, -1);
+ STATIC_SIGN_TEST(int, -898989, -1);
+ STATIC_SIGN_TEST(int, -7732, -1);
+ STATIC_SIGN_TEST(int, 67763, 1);
+ STATIC_SIGN_TEST(int, 112312, 1);
+ STATIC_SIGN_TEST(int, 1123, 1);
+ STATIC_SIGN_TEST(int, -564645, -1);
+ STATIC_SIGN_TEST(int, -100000, -1);
+
 
 #ifndef BOOST_NO_INT64_T
         
+ STATIC_SIGN_TEST(int64_t, -10000000000, -1);
+ STATIC_SIGN_TEST(int64_t, -20000000000, -1);
+ STATIC_SIGN_TEST(int64_t, -1, -1);
+ STATIC_SIGN_TEST(int64_t, 1, 1);
+ STATIC_SIGN_TEST(int64_t, 10000000000, 1);
+ STATIC_SIGN_TEST(int64_t, 12312300000, 1);
+ STATIC_SIGN_TEST(int64_t, 0, 0);
+
         // 64-bit tests
         for (int64_t i = -10000002000; i != -10000000000; ++i) {
                 SIGN_TEST(i, -1);

Added: sandbox/SOC/2010/bits_and_ints/libs/integer/test/static_abs_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/test/static_abs_test.cpp 2010-07-05 11:47:17 EDT (Mon, 05 Jul 2010)
@@ -0,0 +1,33 @@
+// Boost static_abs_test.hpp test program --------------------------------------//
+
+// (C) Copyright Murilo Adriano Vasconcelos 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
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/integer/static_abs.hpp>
+
+#include <iostream>
+
+// Macros to compact code
+#define STATIC_ABS_TEST(t, v, e) \
+BOOST_TEST((::boost::static_abs<t, v>::value == e))
+
+
+// Main testing function
+int main(int, char* [])
+{
+ std::cout << "Doing tests on static_abs." << std::endl;
+
+ STATIC_ABS_TEST(int, -1, 1);
+ STATIC_ABS_TEST(int, 1, 1);
+ STATIC_ABS_TEST(int, -100, 100);
+ STATIC_ABS_TEST(int, 100, 100);
+ STATIC_ABS_TEST(int, -999999, 999999);
+ STATIC_ABS_TEST(int, 999999, 999999);
+ STATIC_ABS_TEST(int, -7, 7);
+
+ return boost::report_errors();
+}
+

Added: sandbox/SOC/2010/bits_and_ints/libs/integer/test/static_gcd_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/test/static_gcd_test.cpp 2010-07-05 11:47:17 EDT (Mon, 05 Jul 2010)
@@ -0,0 +1,45 @@
+// Boost static_abs_test.hpp test program --------------------------------------//
+
+// (C) Copyright Murilo Adriano Vasconcelos 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
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/integer/static_gcd.hpp>
+#include <boost/mpl/integral_c.hpp>
+
+#include <iostream>
+
+
+// Main testing function
+int main(int, char* [])
+{
+ std::cout << "Doing tests on mpl::gcd." << std::endl;
+
+ using boost::mpl::integral_c;
+ using boost::mpl::gcd;
+
+ typedef integral_c<int, 0> zero;
+ typedef integral_c<int, 1> one;
+ typedef integral_c<int, 3> three;
+ typedef integral_c<int, 7> seven;
+ typedef integral_c<int, 8> eight;
+ typedef integral_c<int, 9> nine;
+ typedef integral_c<int, 30> thirty;
+ typedef integral_c<int, 42> fortytwo;
+ typedef integral_c<int, 49> fortynine;
+
+ BOOST_TEST((gcd<one, one>::value == 1));
+ BOOST_TEST((gcd<zero, zero>::value == 0));
+ BOOST_TEST((gcd<seven, zero>::value == 7));
+ BOOST_TEST((gcd<zero, nine>::value == 9));
+ BOOST_TEST((gcd<fortytwo, thirty>::value == 6));
+ BOOST_TEST((gcd<three, seven>::value == 1));
+ BOOST_TEST((gcd<eight, nine>::value == 1));
+ BOOST_TEST((gcd<seven, fortynine>::value == 7));
+
+ return boost::report_errors();
+}
+
+

Added: sandbox/SOC/2010/bits_and_ints/libs/integer/test/static_lcm_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/test/static_lcm_test.cpp 2010-07-05 11:47:17 EDT (Mon, 05 Jul 2010)
@@ -0,0 +1,46 @@
+// Boost static_abs_test.hpp test program --------------------------------------//
+
+// (C) Copyright Murilo Adriano Vasconcelos 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
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/integer/static_gcd.hpp>
+#include <boost/mpl/integral_c.hpp>
+
+#include <iostream>
+
+
+// Main testing function
+int main(int, char* [])
+{
+ std::cout << "Doing tests on mpl::gcd." << std::endl;
+
+ using boost::mpl::integral_c;
+ using boost::mpl::lcm;
+
+ typedef integral_c<int, 0> zero;
+ typedef integral_c<int, 1> one;
+ typedef integral_c<int, 3> three;
+ typedef integral_c<int, 6> six;
+ typedef integral_c<int, 7> seven;
+ typedef integral_c<int, 8> eight;
+ typedef integral_c<int, 9> nine;
+ typedef integral_c<int, 18> eighteen;
+ typedef integral_c<int, 30> thirty;
+ typedef integral_c<int, 49> fortynine;
+
+ BOOST_TEST((static_lcm<one, one>::value) == 1);
+ BOOST_TEST((static_lcm<zero, zero>::value) == 0);
+ BOOST_TEST((static_lcm<six, zero>::value) == 0);
+ BOOST_TEST((static_lcm<zero, seven>::value) == 0);
+ BOOST_TEST((static_lcm<eighteen, thirty>::value) == 90);
+ BOOST_TEST((static_lcm<three, seven>::value) == 21);
+ BOOST_TEST((static_lcm<eight, nine>::value) == 72);
+ BOOST_TEST((static_lcm<seven, fortynine>::value) == 49);
+
+ return boost::report_errors();
+}
+
+


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