Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards


GCD Function Object

Header: <boost/math/common_factor_rt.hpp>

template < typename IntegerType >
class boost::math::gcd_evaluator
   // Types
   typedef IntegerType  result_type;
   typedef IntegerType  first_argument_type;
   typedef IntegerType  second_argument_type;

   // Function object interface
   result_type  operator ()( first_argument_type const &a,
   second_argument_type const &b ) const;

The boost::math::gcd_evaluator class template defines a function object class to return the greatest common divisor of two integers. The template is parameterized by a single type, called IntegerType here. This type should be a numeric type that represents integers. The result of the function object is always nonnegative, even if either of the operator arguments is negative.

This function object class template is used in the corresponding version of the GCD function template. If a numeric type wants to customize evaluations of its greatest common divisors, then the type should specialize on the gcd_evaluator class template.