3 <meta http-equiv=
"Content-Type" content=
"text/html; charset=US-ASCII">
4 <title>GCD Function Object
</title>
5 <link rel=
"stylesheet" href=
"../math.css" type=
"text/css">
6 <meta name=
"generator" content=
"DocBook XSL Stylesheets V1.77.1">
7 <link rel=
"home" href=
"../index.html" title=
"Math Toolkit 2.5.1">
8 <link rel=
"up" href=
"../gcd_lcm.html" title=
"Chapter 11. Integer Utilities (Greatest Common Divisor and Least Common Multiple)">
9 <link rel=
"prev" href=
"synopsis.html" title=
"Synopsis">
10 <link rel=
"next" href=
"lcm_function_object.html" title=
"LCM Function Object">
12 <body bgcolor=
"white" text=
"black" link=
"#0000FF" vlink=
"#840084" alink=
"#0000FF">
13 <table cellpadding=
"2" width=
"100%"><tr>
14 <td valign=
"top"><img alt=
"Boost C++ Libraries" width=
"277" height=
"86" src=
"../../../../../boost.png"></td>
15 <td align=
"center"><a href=
"../../../../../index.html">Home
</a></td>
16 <td align=
"center"><a href=
"../../../../../libs/libraries.htm">Libraries
</a></td>
17 <td align=
"center"><a href=
"http://www.boost.org/users/people.html">People
</a></td>
18 <td align=
"center"><a href=
"http://www.boost.org/users/faq.html">FAQ
</a></td>
19 <td align=
"center"><a href=
"../../../../../more/index.htm">More
</a></td>
22 <div class=
"spirit-nav">
23 <a accesskey=
"p" href=
"synopsis.html"><img src=
"../../../../../doc/src/images/prev.png" alt=
"Prev"></a><a accesskey=
"u" href=
"../gcd_lcm.html"><img src=
"../../../../../doc/src/images/up.png" alt=
"Up"></a><a accesskey=
"h" href=
"../index.html"><img src=
"../../../../../doc/src/images/home.png" alt=
"Home"></a><a accesskey=
"n" href=
"lcm_function_object.html"><img src=
"../../../../../doc/src/images/next.png" alt=
"Next"></a>
26 <div class=
"titlepage"><div><div><h2 class=
"title" style=
"clear: both">
27 <a name=
"math_toolkit.gcd_function_object"></a><a class=
"link" href=
"gcd_function_object.html" title=
"GCD Function Object">GCD Function Object
</a>
28 </h2></div></div></div>
30 <span class=
"bold"><strong>Header:
</strong></span> <a href=
"../../../../../boost/math/common_factor_rt.hpp" target=
"_top"><boost/math/common_factor_rt.hpp
></a>
32 <pre class=
"programlisting"><span class=
"keyword">template
</span> <span class=
"special"><</span> <span class=
"keyword">typename
</span> <span class=
"identifier">IntegerType
</span> <span class=
"special">></span>
33 <span class=
"keyword">class
</span> <span class=
"identifier">boost
</span><span class=
"special">::
</span><span class=
"identifier">math
</span><span class=
"special">::
</span><span class=
"identifier">gcd_evaluator
</span>
34 <span class=
"special">{
</span>
35 <span class=
"keyword">public
</span><span class=
"special">:
</span>
36 <span class=
"comment">// Types
</span>
37 <span class=
"keyword">typedef
</span> <span class=
"identifier">IntegerType
</span> <span class=
"identifier">result_type
</span><span class=
"special">;
</span>
38 <span class=
"keyword">typedef
</span> <span class=
"identifier">IntegerType
</span> <span class=
"identifier">first_argument_type
</span><span class=
"special">;
</span>
39 <span class=
"keyword">typedef
</span> <span class=
"identifier">IntegerType
</span> <span class=
"identifier">second_argument_type
</span><span class=
"special">;
</span>
41 <span class=
"comment">// Function object interface
</span>
42 <span class=
"identifier">result_type
</span> <span class=
"keyword">operator
</span> <span class=
"special">()(
</span> <span class=
"identifier">first_argument_type
</span> <span class=
"keyword">const
</span> <span class=
"special">&</span><span class=
"identifier">a
</span><span class=
"special">,
</span>
43 <span class=
"identifier">second_argument_type
</span> <span class=
"keyword">const
</span> <span class=
"special">&</span><span class=
"identifier">b
</span> <span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
44 <span class=
"special">};
</span>
47 The
<code class=
"computeroutput"><span class=
"identifier">boost
</span><span class=
"special">::
</span><span class=
"identifier">math
</span><span class=
"special">::
</span><span class=
"identifier">gcd
</span></code>_evaluator
48 class template defines a function object class to return the greatest common
49 divisor of two integers. The template is parameterized by a single type, called
50 <code class=
"computeroutput"><span class=
"identifier">IntegerType
</span></code> here. This type
51 should be a numeric type that represents integers. The result of the function
52 object is always nonnegative, even if either of the operator arguments is negative.
55 This function object class template is used in the corresponding version of
56 the GCD function template. If a numeric type wants to customize evaluations
57 of its greatest common divisors, then the type should specialize on the
<code class=
"computeroutput"><span class=
"identifier">gcd_evaluator
</span></code> class template.
60 <table xmlns:
rev=
"http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width=
"100%"><tr>
61 <td align=
"left"></td>
62 <td align=
"right"><div class=
"copyright-footer">Copyright
© 2006-
2010,
2012-
2014 Nikhar Agrawal,
63 Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
64 Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R
åde, Gautam Sewani,
65 Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang
<p>
66 Distributed under the Boost Software License, Version
1.0. (See accompanying
67 file LICENSE_1_0.txt or copy at
<a href=
"http://www.boost.org/LICENSE_1_0.txt" target=
"_top">http://www.boost.org/LICENSE_1_0.txt
</a>)
72 <div class=
"spirit-nav">
73 <a accesskey=
"p" href=
"synopsis.html"><img src=
"../../../../../doc/src/images/prev.png" alt=
"Prev"></a><a accesskey=
"u" href=
"../gcd_lcm.html"><img src=
"../../../../../doc/src/images/up.png" alt=
"Up"></a><a accesskey=
"h" href=
"../index.html"><img src=
"../../../../../doc/src/images/home.png" alt=
"Home"></a><a accesskey=
"n" href=
"lcm_function_object.html"><img src=
"../../../../../doc/src/images/next.png" alt=
"Next"></a>