]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/integer/common_factor_ct.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / integer / common_factor_ct.hpp
CommitLineData
7c673cae
FG
1// Boost common_factor_ct.hpp header file ----------------------------------//
2
3// (C) Copyright Daryle Walker and Stephen Cleary 2001-2002.
4// Distributed under the Boost Software License, Version 1.0. (See
5// accompanying file LICENSE_1_0.txt or copy at
1e59de90 6// https://www.boost.org/LICENSE_1_0.txt)
7c673cae 7
1e59de90 8// See https://www.boost.org for updates, documentation, and revision history.
7c673cae
FG
9
10#ifndef BOOST_INTEGER_COMMON_FACTOR_CT_HPP
11#define BOOST_INTEGER_COMMON_FACTOR_CT_HPP
12
13#include <boost/integer_fwd.hpp> // self include
14#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT, etc.
15
16namespace boost
17{
18namespace integer
19{
20
21// Implementation details --------------------------------------------------//
22
23namespace detail
24{
25 // Build GCD with Euclid's recursive algorithm
26 template < static_gcd_type Value1, static_gcd_type Value2 >
27 struct static_gcd_helper_t
28 {
29 private:
30 BOOST_STATIC_CONSTANT( static_gcd_type, new_value1 = Value2 );
31 BOOST_STATIC_CONSTANT( static_gcd_type, new_value2 = Value1 % Value2 );
32
20effc67 33 #ifndef BOOST_BORLANDC
7c673cae
FG
34 #define BOOST_DETAIL_GCD_HELPER_VAL(Value) static_cast<static_gcd_type>(Value)
35 #else
36 typedef static_gcd_helper_t self_type;
37 #define BOOST_DETAIL_GCD_HELPER_VAL(Value) (self_type:: Value )
38 #endif
39
40 typedef static_gcd_helper_t< BOOST_DETAIL_GCD_HELPER_VAL(new_value1),
41 BOOST_DETAIL_GCD_HELPER_VAL(new_value2) > next_step_type;
42
43 #undef BOOST_DETAIL_GCD_HELPER_VAL
44
45 public:
46 BOOST_STATIC_CONSTANT( static_gcd_type, value = next_step_type::value );
47 };
48
49 // Non-recursive case
50 template < static_gcd_type Value1 >
51 struct static_gcd_helper_t< Value1, 0UL >
52 {
53 BOOST_STATIC_CONSTANT( static_gcd_type, value = Value1 );
54 };
55
56 // Build the LCM from the GCD
57 template < static_gcd_type Value1, static_gcd_type Value2 >
58 struct static_lcm_helper_t
59 {
60 typedef static_gcd_helper_t<Value1, Value2> gcd_type;
61
62 BOOST_STATIC_CONSTANT( static_gcd_type, value = Value1 / gcd_type::value
63 * Value2 );
64 };
65
66 // Special case for zero-GCD values
67 template < >
68 struct static_lcm_helper_t< 0UL, 0UL >
69 {
70 BOOST_STATIC_CONSTANT( static_gcd_type, value = 0UL );
71 };
72
73} // namespace detail
74
75
76// Compile-time greatest common divisor evaluator class declaration --------//
77
78template < static_gcd_type Value1, static_gcd_type Value2 > struct static_gcd
79{
80 BOOST_STATIC_CONSTANT( static_gcd_type, value = (detail::static_gcd_helper_t<Value1, Value2>::value) );
81}; // boost::integer::static_gcd
82
83#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
84template< static_gcd_type Value1, static_gcd_type Value2 > static_gcd_type const static_gcd< Value1, Value2 >::value;
85#endif
86
87// Compile-time least common multiple evaluator class declaration ----------//
88
89template < static_gcd_type Value1, static_gcd_type Value2 > struct static_lcm
90{
91 BOOST_STATIC_CONSTANT( static_gcd_type, value = (detail::static_lcm_helper_t<Value1, Value2>::value) );
92}; // boost::integer::static_lcm
93
94#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
95template< static_gcd_type Value1, static_gcd_type Value2 > static_gcd_type const static_lcm< Value1, Value2 >::value;
96#endif
97
98} // namespace integer
99} // namespace boost
100
101
102#endif // BOOST_INTEGER_COMMON_FACTOR_CT_HPP