File indexing completed on 2025-01-18 09:38:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_INTEGER_COMMON_FACTOR_CT_HPP
0011 #define BOOST_INTEGER_COMMON_FACTOR_CT_HPP
0012
0013 #include <boost/integer_fwd.hpp> // self include
0014 #include <boost/config.hpp> // for BOOST_STATIC_CONSTANT, etc.
0015
0016 namespace boost
0017 {
0018 namespace integer
0019 {
0020
0021
0022
0023 namespace detail
0024 {
0025
0026 template < static_gcd_type Value1, static_gcd_type Value2 >
0027 struct static_gcd_helper_t
0028 {
0029 private:
0030 BOOST_STATIC_CONSTANT( static_gcd_type, new_value1 = Value2 );
0031 BOOST_STATIC_CONSTANT( static_gcd_type, new_value2 = Value1 % Value2 );
0032
0033 #ifndef BOOST_BORLANDC
0034 #define BOOST_DETAIL_GCD_HELPER_VAL(Value) static_cast<static_gcd_type>(Value)
0035 #else
0036 typedef static_gcd_helper_t self_type;
0037 #define BOOST_DETAIL_GCD_HELPER_VAL(Value) (self_type:: Value )
0038 #endif
0039
0040 typedef static_gcd_helper_t< BOOST_DETAIL_GCD_HELPER_VAL(new_value1),
0041 BOOST_DETAIL_GCD_HELPER_VAL(new_value2) > next_step_type;
0042
0043 #undef BOOST_DETAIL_GCD_HELPER_VAL
0044
0045 public:
0046 BOOST_STATIC_CONSTANT( static_gcd_type, value = next_step_type::value );
0047 };
0048
0049
0050 template < static_gcd_type Value1 >
0051 struct static_gcd_helper_t< Value1, 0UL >
0052 {
0053 BOOST_STATIC_CONSTANT( static_gcd_type, value = Value1 );
0054 };
0055
0056
0057 template < static_gcd_type Value1, static_gcd_type Value2 >
0058 struct static_lcm_helper_t
0059 {
0060 typedef static_gcd_helper_t<Value1, Value2> gcd_type;
0061
0062 BOOST_STATIC_CONSTANT( static_gcd_type, value = Value1 / gcd_type::value
0063 * Value2 );
0064 };
0065
0066
0067 template < >
0068 struct static_lcm_helper_t< 0UL, 0UL >
0069 {
0070 BOOST_STATIC_CONSTANT( static_gcd_type, value = 0UL );
0071 };
0072
0073 }
0074
0075
0076
0077
0078 template < static_gcd_type Value1, static_gcd_type Value2 > struct static_gcd
0079 {
0080 BOOST_STATIC_CONSTANT( static_gcd_type, value = (detail::static_gcd_helper_t<Value1, Value2>::value) );
0081 };
0082
0083 #if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
0084 template< static_gcd_type Value1, static_gcd_type Value2 > static_gcd_type const static_gcd< Value1, Value2 >::value;
0085 #endif
0086
0087
0088
0089 template < static_gcd_type Value1, static_gcd_type Value2 > struct static_lcm
0090 {
0091 BOOST_STATIC_CONSTANT( static_gcd_type, value = (detail::static_lcm_helper_t<Value1, Value2>::value) );
0092 };
0093
0094 #if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
0095 template< static_gcd_type Value1, static_gcd_type Value2 > static_gcd_type const static_lcm< Value1, Value2 >::value;
0096 #endif
0097
0098 }
0099 }
0100
0101
0102 #endif