Boost C++ 库

……是世界上备受推崇且设计精良的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu, 《C++ 编码标准》

Boost.Integer - Boost C++ 函数库
Next

Boost.Integer

Beman Dawes

Daryle Walker

Gennaro Prota

John Maddock

根据 Boost 软件许可证 1.0 版分发。(请参阅随附的 LICENSE_1_0.txt 文件或访问 https://boost.ac.cn/LICENSE_1_0.txt 获取副本)


Boost.Integer 提供了整数类型支持,在泛型编程中尤其有用。它提供了根据整数属性(如位数或支持的最大值)选择整数类型的方法,以及编译时位掩码选择。它提供了一个 `std::numeric_limits` 的派生类,为 `min` 和 `max` 提供整型常量表达式。最后,它提供了两个编译时算法:确定编译时值中的最高二的幂;以及计算常量表达式的 min 和 max。

Component

头文件

目的

Forward Declarations.(前向声明)

<boost/integer_fwd.hpp>

Classes and class templates forward declarations - for use when just the name of a class is needed.(类和类模板的前向声明 - 当只需要类名时使用。)

Integer Traits(整数特性).

<boost/integer_traits.hpp>

The class template boost::integer_traits, derives from std::numeric_limits and adds const_min and const_max members.(类模板 `boost::integer_traits`,派生自 `std::numeric_limits` 并添加了 `const_min` 和 `const_max` 成员。)

Integer Type Selection(整数类型选择).

<boost/integer.hpp>

Templates for integer type selection based on properties such as maximum value or number of bits: Use to select the type of an integer when some property such as maximum value or number of bits is known. Useful for generic programming.(用于根据最大值或位数等属性选择整数类型的模板:当已知最大值或位数等属性时,用于选择整数的类型。适用于泛型编程。)

Greatest Common Divisor and Least Common Multiple(最大公约数和最小公倍数).

<boost/integer/common_factor_rt.hpp> and <boost/integer/common_factor_ct.hpp>

Functions gcd and lcm plus function objects and compile time versions.(函数 `gcd` 和 `lcm`,以及函数对象和编译时版本。)

Integer Masks(整数掩码).

<boost/integer/integer_mask.hpp>

Templates for the selection of integer masks, single or lowest group, based on the number of bits: Use to select a particular mask when the bit position(s) are based on a compile-time variable. Useful for generic programming.(用于根据位数选择整数掩码(单个或最低组)的模板:当位位置基于编译时变量时,用于选择特定掩码。适用于泛型编程。)

Compile time log2 Calculation(编译时 log2 计算).

<boost/integer/static_log2.hpp>

Template for finding the highest power of two in a number: Use to find the bit-size/range based on a maximum value. Useful for generic programming.(用于查找数字中最高二的幂的模板:用于根据最大值查找位大小/范围。适用于泛型编程。)

Compile time min/max calculation(编译时 min/max 计算).

<boost/integer/static_min_max.hpp>

Templates for finding the extrema of two numbers: Use to find a bound based on a minimum or maximum value. Useful for generic programming.(用于查找两个数字的极值(min/max)的模板:用于根据最小值或最大值查找界限。适用于泛型编程。)

Extended Euclidean algorithm(扩展欧几里得算法).

<boost/integer/extended_euclidean.hpp>

Solves mx + ny = gcd(x,y) for x and y.(求解 `mx + ny = gcd(x,y)` 中的 `x` 和 `y`。)

Modular multiplicative inverse(模乘法逆元).

<boost/integer/mod_inverse.hpp>

Given a and m, solves ax = 1 mod m for x.(给定 `a` 和 `m`,求解 `ax` = 1 mod `m` 中的 `x`。)


Next