Compare commits

..

403 Commits

Author SHA1 Message Date
e7ed9918c1 Remove C++03 CI jobs, use gcc-11 libstdc++ in clang-12 through 15. 2023-11-17 20:05:19 +03:00
becbd39cc4 Switch to boost::core::invoke_swap.
boost::swap is deprecated and will be removed. Use boost::core::invoke_swap
as a replacement.
2023-09-03 00:24:44 +03:00
28ba36fd3a Add clang-16 CI jobs, switch to clang-15 from stock Ubuntu repos. 2023-06-05 03:16:14 +03:00
8ce66ab37e Updated to GHA checkout@v3 to avoid deprecation warnings. 2022-10-18 17:57:33 +03:00
d4157bdf38 GitHub Actions config update.
- Added gcc-12 and clang-14 through 15 jobs.
- Added C++23 testing for gcc and clang on Linux.
- Updated clang version for UBSAN job.
- Updated Ubuntu version for clang jobs to avoid having to use external APT
  repository.
- Updated python package installation for compatibility with Ubuntu 22.04.
2022-09-10 01:21:36 +03:00
721fe9f562 Switched gcc-9 to ubuntu-20.04 GHA CI image. 2022-08-14 17:52:55 +03:00
88457d2de5 Replaced ubuntu-18.04 GHA CI images with containers.
Also use ubuntu-latest image for jobs that are running in a container.
2022-08-14 13:55:47 +03:00
d22bf3ea37 Switch to macos-11 GHA image as macos-10.15 is deprecated. 2022-08-12 15:59:03 +03:00
c659255289 Added VS2022 job and C++20 and C++latest jobs to AppVeyor CI. 2022-06-06 02:55:11 +03:00
49195acf60 Enabled testing with GNU extensions in GitHub Actions. 2022-01-16 18:29:54 +03:00
bc9b0e6177 Implemented integer_log2 in terms of countl_zero from Boost.Core.
This allows to use compiler intrinsics and specialized hardware
instructions to compute log2, which results in better performance.

Also, added tests for the generic implementation using Boost.Multiprecision
integers.

Closes https://github.com/boostorg/integer/issues/31.
2022-01-16 15:20:37 +03:00
c6564a2d2b Merge pull request #26 from bernardosulzbach/documentation-typo-fix
Fixed a typo in ::least
2022-01-15 22:19:23 +03:00
16ef530fcf Use up to date includes for lightweight_test.hpp. 2021-12-21 20:45:00 +03:00
c5df07cb21 Simplified integer_log2 implementation.
Removed unnecessary template specializations, removed workaround for
compilers not supporting partial template specializations. Use unsigned
integers for bit counting, which allows to replace the division with
a shift.
2021-12-21 20:39:22 +03:00
a832e8fe65 Added a test for integer_log2. 2021-12-21 20:36:24 +03:00
0cd1879903 Fixed a link to library docs and silenced b2 warning about unescaped character. 2021-11-19 18:25:39 +03:00
4c1e36b023 Updated check for apt-add-repository capabilities.
In Ubuntu 20.04 there appeared an updated version of the
software-properties-common package in focal-updates, which ships a newer
apt-add-repository version that doesn't support -P/-S/-U command line arguments.

Since we cannot rely on package version checks to determine apt-add-repository
capabilities, we have to parse its --help output instead.

Also, made source list processing more protected against spaces.
2021-11-16 00:44:02 +03:00
cf25880755 Fixed git version check on Mac OS. 2021-09-26 20:39:29 +03:00
5b23a363ae Updated links in README.md. 2021-09-15 22:14:36 +03:00
4669ec7e78 Added GHA CI timeout. 2021-09-15 21:29:17 +03:00
ee1325ee11 Removed CMake tests from GHA config. 2021-09-12 20:34:44 +03:00
c3ba27a249 Added GitHub Actions links to README.md. 2021-09-12 20:25:22 +03:00
2a78052e85 Added GitHub Actions config. 2021-09-12 20:21:17 +03:00
a92f2eb98f Updated test matrix icon for develop in README.md. 2021-09-12 19:53:12 +03:00
c972712386 Updated README.md to remove Travis CI and add other links. 2021-09-12 19:52:08 +03:00
fa6b7c465e Removed Travis CI config.
Since Travis CI no longer runs free jobs for open source projects,
we are switching to other CI services.
2021-09-12 19:45:37 +03:00
8fd622545f Update CMakeLists.txt 2021-06-10 00:59:52 +03:00
be13dbce6d Merge pull request #28 from jzmaddock/cxx11-fixes
Fixes for cxx11 changes to dependencies:
2021-02-18 22:46:31 +03:00
2ca7c7b6e3 Fixes for cxx11 changes to dependencies:
Make Multiprecision tests depend on <type_traits> and BOOST_NO_CXX11_HDR_TYPE_TRAITS.
Use specific Boost.Random headers and not <boost/random.hpp> as the latter pulls in some of Boost.Math which has now moved to C++11.
2021-02-18 18:29:03 +00:00
ba7ea7f846 Fixed a typo in ::least 2021-01-31 14:03:24 +01:00
092d94c833 Converted all links to www.boost.org to https.
Closes https://github.com/boostorg/integer/pull/25.
2021-01-20 11:34:42 +03:00
100f5e51bd [skip ci] Merge pull request #23 from eldiener/develop
[skip ci] Add "cxxstd" json field
2021-01-20 11:19:43 +03:00
0322c761b8 [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's compilation level, without having to search the library's documentation to find this out. 2021-01-19 22:55:23 -05:00
831869a51f Added checks for C++11 features required by Boost.Multiprecision.
As of 2021, Boost.Multiprecision does not support C++03 and fails tests
of Boost.Integer. To mitigate, we replicate the preprocessor checks of
Boost.Multiprecision to disable its use in Boost.Integer tests in C++03
mode.
2021-01-11 15:27:10 +03:00
45df7932c1 Update README.md 2021-01-11 09:53:24 +00:00
3723b0694a Merge pull request #22 from sdarwin/drone
Drone config
2021-01-07 19:40:22 +00:00
e683a37a4d add drone config [ci skip] 2021-01-07 18:12:46 +00:00
a9de4c0076 Added explicit specification of addres-model=32 for MSVC-9 to 12.
Works around https://github.com/boostorg/build/issues/659.
2020-12-12 10:58:21 +03:00
54dcfa677d Added a workaround for C++20 ostream having deleted operator<< for wchar_t. 2020-05-23 20:05:02 +03:00
560df48888 Added gcc 10 build jobs to Travis CI. 2020-05-22 18:42:46 +03:00
6bb937fa5f Fixed compilation of gcd in C++20 mode with clang 10.
Due to the new overload resolution rules for comparison operators in C++20,
the comparison became ambiguous.
2020-05-07 14:35:47 +03:00
a6a6b1f064 Added clang-10 jobs to Travis CI. 2020-05-05 23:22:14 +03:00
9e6b3d375a Added missing includes. 2020-05-02 18:34:43 +03:00
5e2a2722f1 Use BOOST_ASSERT instead of assert. 2020-05-02 18:18:10 +03:00
5ae18d139e Use BOOST_BORLANDC in integer_log2.hpp 2020-05-02 18:16:16 +03:00
58da9b5aa8 Merge pull request #21 from eldiener/develop
Changes for Embarcadero C++ clang-based compilers, targeting Boost 1.74
2020-05-02 18:14:59 +03:00
6cb625550f Change to run MP testing in integer for Embarcadero C++ clang-based compilers. 2020-04-11 12:37:31 -04:00
c7a22c9bac Embarcadero C++ clang-based compilers can not handle multiprecision comparisons in lightwieght tests, but gives a linker error. This has been reported to Embarcadero as a bug. 2020-04-10 11:56:41 -04:00
52c02d1237 Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers. 2020-03-29 08:30:32 -04:00
bee5818e18 Disabled all but one OS X jobs because they are slow on Travis CI. 2019-10-22 15:04:28 +03:00
1067b2d170 Updated CI configs, added compilers. 2019-10-22 00:38:27 +03:00
8cfbb2a222 Update Travis configuration 2019-10-16 23:34:03 -04:00
00154b31a5 Merge pull request #20 from tinko92/develop
Fixes a broken link to the Microsoft KB.
2019-04-24 05:32:58 +10:00
63f14838a0 Fix a broken link to the Microsoft KB. 2019-04-23 21:29:53 +02:00
33c165552c Fixed incorrect loop termination in lcm_range.
lcm_range used to incorrectly terminate on value of 1. Instead, it should
terminate on 0 since any further elements of the range no longer affect
the result of the function.

Also, added tests for the gcd_range and lcm_range functions verifying
that they terminate their loops at the correct points.
2019-03-26 01:55:18 +03:00
5195d682ec Enabled multiple git fetch jobs while executing depinst in CI. Increased the number of jobs to 8. 2019-01-15 13:51:57 +03:00
49dd6f5645 Use the actual number of logical CPUs for the number of CI build/test jobs. 2019-01-03 23:10:05 +03:00
96f430b7e2 Re-added manual checkout of libs/config in CI as Boost.Build depends on it. 2018-12-20 20:45:39 +03:00
39082b1bc5 Use a separate submodule update step with parallel checkouts to speedup CI job startup. 2018-12-18 22:33:50 +03:00
51d1b16bfd Added tools/boost_install and libs/headers manual checkout to CI jobs. 2018-12-18 21:57:43 +03:00
131107704f Added an experimental partial CMakeLists.txt for dependency tracking in CMake projects. 2018-12-18 19:35:32 +03:00
eaf2561e95 Merge pull request #17 from NAThompson/remove_optional
Return integer with zero signaling common factor rather than boost::optional
2018-12-05 13:06:55 +03:00
29e3ae824c Fully qualify call. 2018-12-04 12:09:31 -07:00
0af165bf6d Merge branch 'remove_optional' of https://github.com/NAThompson/integer into remove_optional 2018-12-04 11:31:12 -07:00
080f2bdfdc Take care of the case where integer type Z has explicit constructor. 2018-12-04 11:27:37 -07:00
289939a640 Merge branch 'develop' into remove_optional 2018-12-04 10:57:02 -07:00
51b259da19 Return integer with zero signaling common factor rather than boost::optional<Z>. 2018-12-04 10:55:03 -07:00
4bc1a5eb75 Extracted DISABLE_MP_TESTS macro definition to a common header. 2018-11-05 22:56:03 +03:00
682d4ac66b Fixed tests not compiling on MSVC 8, added missing includes. 2018-11-04 01:00:57 +03:00
2f634ca78b Added missing includes, remove C++11 requirement, other code cleanup.
Also, use Boost.Swap instead of the direct unqualified call to std::swap
and boost::enable_if_c instead of std::enable_if.
2018-11-03 23:10:44 +03:00
2b08ca9368 Removed auto-generated docs from git. 2018-11-03 22:48:58 +03:00
aa68e17f2e Merge pull request #11 from NAThompson/develop
Modular exponentiation, modular multiplicative inverse
2018-11-03 22:46:30 +03:00
cad4623876 Regenerate documentation. 2018-11-02 13:45:45 -06:00
9a7f24e8ca Merge remote-tracking branch 'upstream/develop' into develop
Merge upstream [CI SKIP]
2018-11-01 17:12:50 -06:00
3599683975 #include <boost/config.hpp> 2018-11-01 12:11:09 -06:00
b3680b77fd Disable tests for gcc < version 5 2018-11-01 12:02:18 -06:00
099cf261b0 Added clang 7 CI job. 2018-11-01 20:24:04 +03:00
ab509ca840 Use https in URLs in readme. 2018-11-01 16:33:47 +03:00
37204ea892 Corrected a typo in readme. 2018-11-01 16:25:15 +03:00
5df4961448 Added CI build statuses to readme. 2018-11-01 16:14:20 +03:00
95a19b6364 Merge pull request #14 from boostorg/danieljames-patch-1
Fix json error
2018-10-30 11:46:15 +03:00
8674c6724f Fix json error 2018-10-30 07:47:30 +00:00
a7da90a79e Make changes suggested by reviewer. 2018-10-29 13:10:02 -06:00
9312962a68 Use using std::swap; swap(n,m) rather than std::swap(n,m) [CI SKIP] 2018-10-29 13:00:30 -06:00
df7adb52ca Use std::enable_if to enable SFINAE rather than static_assert 2018-10-29 11:58:18 -06:00
6c58aa9a48 Merge remote-tracking branch 'upstream/develop' into develop 2018-10-29 08:53:12 -06:00
cd60c4c9f9 [CI SKIP] Disable multiprecision in certain compilers. 2018-10-29 08:52:20 -06:00
7c5def9d39 Disable Boost.Multiprecision tests for gcc 4.7 in C++11 mode.
The compiler fails in Boost.TypeTraits which is used in Boost.Multiprecision.
2018-10-29 12:25:55 +03:00
791a139a51 Disable testing C++14 and 17 on clang 3.8 and 3.9.
The compiler uses libstdc++ from gcc 4.8, which does not support C++14.
In particular, it is trying to import the missing ::gets function.
2018-10-29 12:13:42 +03:00
835ac98a23 Fail libgmpxx detection on Linux if libstdc++ is not used as the std library.
libgmpxx was built against libstdc++, so if the application uses e.g. libc++,
linking fails because of the standard symbols mismatch.
2018-10-29 12:07:06 +03:00
f76d776698 Define main when gcc version is < 5. 2018-10-28 23:28:28 -06:00
c4c3373708 Don't run tests on gcc 4 and earlier; not worth the pain. 2018-10-28 22:40:36 -06:00
bbb1da275b Merge master; fix Jamfile 2018-10-28 21:14:31 -06:00
b5d5c56e68 Use boostdep to install library dependencies. 2018-10-28 19:51:00 +03:00
3961dc2f1e Changed clang 3.9 toolset apt source to Trusty to fix compilation errors. Aggregated multiple C++ versions to CI jobs and added more toolsets. 2018-10-28 19:11:29 +03:00
645edc971d Added Boost.IO to CI checkout as it's required by Boost.Random. 2018-10-28 01:12:49 +03:00
e00ffe97ae Merge branch 'develop' 2018-10-27 20:26:07 +03:00
6340dec871 Add boost libraries added as dependencies to tests. 2018-10-26 19:29:58 -06:00
de0d24733b Remove dependency on boost/typeindex in tests. 2018-10-26 19:23:11 -06:00
0c6ec8088d Just use asserts, omg. 2018-10-26 18:42:39 -06:00
f21a8e301a Make .travis.yml configure the test framework. 2018-10-26 17:56:21 -06:00
cdefe039ee I'm flailing with this one. 2018-10-26 17:51:31 -06:00
f6525ae186 (Hopefully) green up build by giving path to Boost.Test. 2018-10-26 17:11:28 -06:00
e0646cb7ec Add template argument to green up build. Remove discrete log as we do not have an overflow-resistant mul_mod in boost. 2018-10-26 16:58:30 -06:00
3632ae43b2 Update docs. [CI SKIP] 2018-10-26 12:05:47 -06:00
2d463f3ee7 a*p % m may overflow, do not perform naive multiplication in unit tests or undefined behavior may result. [CI SKIP] 2018-10-26 11:19:43 -06:00
3f1603938c Revert change as the previous algorithm overflows for all inputs >= half the bit length of the type. 2018-10-25 18:05:14 -06:00
54d0e4c63e [ci skip] Trade out algorithm from 'The Joy of Factoring' to Wikipedia's version which reduces the number of required temporaries. In fact, the speedup is not large, but the code is more compact, and for larger types, the difference becomes more noticeable. 2018-10-25 14:28:39 -06:00
87e5b365d8 Return custom struct from extended Euclidean algorithm rather than tuple. Reduce number of operations for tests to reduce CI system workload. Disable discrete log tests until we have time to figure out why they are failing. 2018-10-25 09:38:16 -06:00
ada03a59d7 Remove dependency on boost.format, remove unfettered use of auto in order to move towards C++03 compatibility, use BOOST_THROW_EXCEPTION. 2018-10-24 14:29:22 -06:00
9167594533 Merge branch 'develop' of https://github.com/boostorg/integer into develop 2018-10-24 13:11:30 -06:00
1c586d6dd0 Merge pull request #13 from NAThompson/deprecate_pending_3
[ci skip] Deprecate boost/pending/integer_log2.hpp
2018-10-24 17:59:09 +03:00
6a97e49614 Added a readme. Added myself as a maintainer. 2018-10-24 17:56:15 +03:00
661986dd3d [ci skip] Deprecate boost/pending/integer_log2.hpp 2018-02-11 12:32:14 -06:00
faa61cd911 [ci skip] It is *not* the case that a discrete log exists when the base and modulus are coprime. Take 4^x = 2 mod 5 as a counterexample. Change API accordingly. 2018-02-10 17:51:59 -06:00
4f4f3eda37 [ci skip] Fix docs to use less verbose names for modular multiplicative inverse (mod_inverse) 2018-02-10 16:07:17 -06:00
b3966428c4 [ci skip] Add test of short int to see if there's any obvious places for overflow (none are obvious, but no guarantees they still aren't there). Print basic information about the test to console so that failures are easier to track down. 2018-02-10 13:56:11 -06:00
8c415f77b1 [ci skip] Use less verbose naming. Add asserts as verfication of algorithms is a negligible fraction of total runtime. Use boost::multiprecision::powm and boost::multiprecision::sqrt rather than one-offs. 2018-02-09 17:19:26 -06:00
fc4d657201 [ci skip] Modular exponentiation, modular multiplicative inverse, extended Euclidean algorithm, discrete logarithm. 2018-01-28 14:47:14 -06:00
919c5277c1 Merge pull request #10 from Lastique/patch-2
Correct make_odd return type inconsistency
2017-08-27 12:07:50 -04:00
bc2349f71b Corrected make_odd return type inconsistency.
Make gcd_traits<signed char>::make_odd return unsigned int, similar to all other gcd_traits specializations. Also, correct the local variable types that receive the result of make_odd to avoid warnings about unintended conversion.
2017-08-20 01:57:09 +03:00
66dbc2c70a Merge pull request #9 from boostorg/develop
Merge develop to master
2017-06-10 08:29:02 +01:00
10026d9b6f Disable some tests on older compilers that we know won't pass. 2017-06-09 19:47:18 +01:00
3e84cde165 Merge branch 'develop' of https://github.com/boostorg/integer into develop 2017-06-09 14:52:03 +01:00
5c129565d5 CI: add missing appveyor dependency 2017-06-09 14:51:50 +01:00
9a26557f38 Merge pull request #7 from DanielaE/fix/narrowing
fix narrowing warnings due to integer promotion.
2017-06-08 19:25:00 +01:00
6ebccd6c80 fix narrowing warnings due to integer promotion.
Signed-off-by: Daniela Engert <dani@ngrt.de>
2017-06-08 17:40:32 +02:00
6662dbdbbd CI: Fix appveyor bjam arguments. 2017-06-04 08:02:14 +01:00
81a7c92b6c CI: Add missing dependency to utility. 2017-06-01 08:48:02 +01:00
4406ec8039 Merge branch 'develop' of https://github.com/boostorg/integer into develop 2017-05-31 18:45:28 +01:00
8e63e7f284 CI: Add more testers and minimise dependencies. 2017-05-31 18:45:16 +01:00
0c956331a0 Fix gmp test failures 2017-05-09 19:52:20 +01:00
943d63e309 Fix use of check-target-builds in Jamfile. 2017-05-09 18:03:03 +01:00
7ccb820893 Test mpz_class when available.
And fix errors compiling with that type.
2017-05-07 13:15:15 +01:00
84ded579f3 Qualify recursive calls to avoid ambiguity for types that have their own gcd/lcm 2017-05-04 11:12:33 +01:00
c1a08d3185 We can enable compiler intrinsics with GCC in C++14 mode after all 2017-04-30 18:49:47 +01:00
53306630db Fix for Oracle 12.4 compiler 2017-04-27 17:23:40 +00:00
1d934167fd Tentative fix for overload resolution issue with Oracle C++. 2017-04-26 19:51:03 +01:00
9c75396c05 Fix more explicit instantiations in test cases. 2017-04-26 19:11:18 +01:00
7c0151c93a Enumerators don't need a final , in their list. 2017-04-26 18:30:11 +01:00
52e2dba49b Merge branch 'develop' of https://github.com/boostorg/integer into develop 2017-04-26 18:24:22 +01:00
395735a193 Add tests for multiprecision types and fix test program to still compile. 2017-04-26 18:24:09 +01:00
240b96ddec Add appveyor.yml 2017-04-25 17:26:57 +03:00
6af0e7ee85 Merge branch 'develop' of https://github.com/boostorg/integer into develop 2017-04-24 19:20:02 +01:00
4991d82385 Need to take abs of return value in short-circuit gcd code. 2017-04-24 19:19:48 +01:00
2b133e8ea8 Merge branch 'develop' of https://github.com/boostorg/integer into develop 2017-04-24 21:08:11 +03:00
55e81c5ba7 Fetch test dependencies in .travis.yml 2017-04-24 21:07:48 +03:00
52ce75ed65 Merge branch 'develop' of https://github.com/boostorg/integer into develop
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2017-04-24 18:52:16 +01:00
3e43dd6fc2 Update history. 2017-04-24 18:50:19 +01:00
b2dcad8daf Add .travis.yml 2017-04-24 20:49:14 +03:00
58d53beae4 Add missing #include for older compilers. 2017-04-24 18:18:36 +01:00
f5eff7d83d MSVC-8 has no <intrin.h>. 2017-04-24 18:13:56 +01:00
efb84707f0 Update docs to match new gcd/lcm code. 2017-04-24 13:01:57 +01:00
beb6871864 Switch over to using new Boost.Math version of gcd/lcm.
Please refer to the Boost.Math revision log for details of changes, but in summary:
* New version of gcd/lcm internals by Jeremy Murphy include mixed-binary algorithm and better selection logic.
* Support is now included for gcd's of polynomials.
* Full C++14 constexpr support.
2017-04-23 13:01:09 +01:00
162e48d14a Remove dependency to mpl and type_traits. 2017-03-31 18:34:14 +01:00
74939edefe Merge branch 'cpp14' into develop 2017-03-30 19:07:30 +01:00
f650385f65 Disable test case that causes msvc internal error. 2017-03-30 18:50:57 +01:00
39d9701857 Enable one more noexcept test 2017-03-28 19:30:48 +01:00
45cc025bbd Merge branch 'bugfix/bitwise-not-and-gcc6' of https://github.com/Flast/boost-integer into cpp14 2017-03-28 19:28:51 +01:00
13b36d8432 Add tests for C++14 support. 2017-03-28 19:06:13 +01:00
a52bae3639 Improve C++14 support:
* Make functions constexpr.
* Make functions noexcept where appropriate.
* Add test case for the above.
2017-03-28 18:57:50 +01:00
0d964fe6fc Add, and update, documentation build targets. 2016-10-10 11:39:50 -05:00
13b153c657 Add, and update, documentation build targets. 2016-10-07 23:07:34 -05:00
89cec128bd Fix compile error on GCC6 or later.
Bitwise not yields integral promotion and to be signed type.
2016-07-30 16:12:07 +09:00
14020f6f6c Merge branch 'develop' 2015-03-09 08:10:54 +01:00
175a1caa58 Placed GCD and LCM typdefs and declarations in integer_fwd.hpp inside namespace boost::integer (was in boost::math) and checked that expected tests pass (and expected fails fail).
(Major update to Boost.Integer docs available for review at https://dl.dropboxusercontent.com/u/43940943/modular-boost/libs/integer/index.html
on branch doc-revision).
2015-01-29 11:53:02 +00:00
1ff7278d5f Added compile fail test for uint_t<65>. related to #6169. 2015-01-25 17:26:09 +01:00
a12b96c011 manage with #4881. 2015-01-25 17:11:04 +01:00
7ffb75bb43 manage with #6694 Boost.Integer part. 2015-01-25 17:03:09 +01:00
83feb20e51 Missing #include
Test case uses mpl:: types without including the needed header - exposed by ongoing type traits rewrite.
2015-01-23 19:05:59 +00:00
66ae9dc182 Merge branch 'develop' 2015-01-18 20:04:57 +02:00
c5370a9705 Fix ambiguous 'detail' errors under msvc-8.0. 2015-01-18 20:04:09 +02:00
603f412c1b Merge branch 'develop' 2015-01-13 20:54:39 +02:00
8dae82faeb Replace math with integer, untabify. 2015-01-13 20:53:02 +02:00
1a72919419 Add common_factor_test to test/Jamfile, switch to lightweight_test. 2015-01-13 20:33:50 +02:00
acf272ee7d Move common_factor headers to integer/ 2015-01-13 19:55:58 +02:00
de8b1d86f4 Merge branch 'develop' 2015-01-13 19:50:23 +02:00
7ada3ee926 Reapply final math-gcd.qbk commit. 2015-01-13 19:49:06 +02:00
4622a12f01 Added licence info.
[SVN r84266]
2015-01-13 19:42:24 +02:00
88b3ac5619 Change to quickbook 1.6. Change to use chapters at the top level. Big search and replace on link names.
[SVN r84201]
2015-01-13 19:42:11 +02:00
ae8ee599ac Reorganise directory structure to make things easier to find and maintain.
[SVN r84143]
2015-01-13 19:42:11 +02:00
9677dbd035 Added missing #include <iostream>
[SVN r81697]
2015-01-13 19:42:10 +02:00
e394f8fd86 Change PDF URL to SF download page. Add optional index generation.
[SVN r67545]
2015-01-13 19:42:10 +02:00
95a4f1e235 Update docs to match code.
[SVN r63409]
2015-01-13 19:42:09 +02:00
f194e652ab Fix links to pdfs in the maths documentation.
[SVN r45861]
2015-01-13 19:42:09 +02:00
e64047b7c7 Fix typo in example. Added links to PDF versions of the docs. Regenerated all the docs to fix people links.
[SVN r43346]
2015-01-13 19:42:08 +02:00
dcf16f30bc Added refactored docs for existing Boost.Math libraries.
[SVN r39851]
2015-01-13 19:42:08 +02:00
b70c89a3ff Remove BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Process #ifndef...#else...#endif blocks.

[SVN r86245]
2015-01-13 19:41:33 +02:00
9f43b6a7d6 Removed missed usage of deprecated macros in Boost.Math
[SVN r81586]
2015-01-13 19:41:32 +02:00
fecb6b5509 Fix numeric_limits specialization.
[SVN r79419]
2015-01-13 19:41:32 +02:00
eea434b0f1 eliminated test_case_template.hpp
[SVN r74735]
2015-01-13 19:41:31 +02:00
72b569f84f MSVC warning suppression.
[SVN r69509]
2015-01-13 19:41:31 +02:00
ce4bd6cc98 Fix signed/unsigned comparison warnings when char is unsigned.
[SVN r63496]
2015-01-13 19:41:31 +02:00
d38557f5f3 Make the compile time gcd facilities work with greatest integer types, and be mpl compatible.
[SVN r63408]
2015-01-13 19:41:30 +02:00
5174291e08 Fix failures when used with an expression-template enabled number type such as the gmpxx clases. Add additional concept check for integer code using gmp classes. Fixes #4139.
[SVN r61837]
2015-01-13 19:41:29 +02:00
7c528c325e Tweaked files to pass inspection report; one file had some min/max violations; but all had to have 'boostinspect:nolicense' set because a copyrighter, Paul Moore, has disappeared, so his files can never be changed to the main Boost license
[SVN r47847]
2015-01-13 19:41:29 +02:00
bdafb07012 Replace a couple of non-ascii symbols.
[SVN r46943]
2015-01-13 19:41:28 +02:00
fe60fee95b Fix more inspect report issues, and regenerated the docs.
[SVN r46839]
2015-01-13 19:41:28 +02:00
e20431e713 Changed long long to boost::long_long_type and unsigned long long to boost::ulong_long_type. A couple of other typo corrections, to get the code compiling with g++ -pedantic.
[SVN r44877]
2015-01-13 19:41:27 +02:00
217fa37de2 Fix min/max usage violation.
[SVN r43145]
2015-01-13 19:41:27 +02:00
307fee457a Fix Borland infinite looping issue.
[SVN r39723]
2015-01-13 19:41:27 +02:00
a9d91361fa Undo previous fix, it causes regressions.
[SVN r37022]
2015-01-13 19:41:26 +02:00
f1076ff42c STLport workaround.
[SVN r37001]
2015-01-13 19:41:26 +02:00
18a37cbab2 various fixes for old compilers
[SVN r36259]
2015-01-13 19:41:25 +02:00
80b59192ae Made the GCD specializations for '(unsigned) long long' and '(unsigned) __int64' mutually exclusive, following the lead of <boost/cstdint.hpp>.
[SVN r35999]
2015-01-13 19:41:25 +02:00
1f5f827a5e Changed GCD for built-in integer types to use the binary-GCD algorithm
[SVN r35850]
2015-01-13 19:41:25 +02:00
56b287a590 Added custom integer types, signed and unsigned, with and without std::numeric_limits<> specializations, to test
[SVN r35830]
2015-01-13 19:41:24 +02:00
c8faa83d47 Changed test to use Boost.Test's unit test system
[SVN r35815]
2015-01-13 19:41:24 +02:00
c041451a54 Added missing 'typename'
[SVN r27219]
2015-01-13 19:41:23 +02:00
6e6179b932 Replaced BOOST_TEST
[SVN r27050]
2015-01-13 19:41:23 +02:00
791b547d25 Changed files to BSL based on permissions in blanket-permission.txt
[SVN r25451]
2015-01-13 19:41:22 +02:00
cd696b2f6a License update
[SVN r24180]
2015-01-13 19:41:22 +02:00
fadad77a39 Merged fix from release branch to main trunk.
[SVN r15607]
2015-01-13 19:41:22 +02:00
9880cf69dc Adjusted for moving the Compile-Time and Run-Time GCD and LCM components to new, separate headers
[SVN r14273]
2015-01-13 19:41:21 +02:00
56bd3fd0b3 Moved the Compile-Time and Run-Time components to separate headers
[SVN r14272]
2015-01-13 19:41:21 +02:00
bb16ad8ea0 Added tests for unsigned int types
[SVN r13685]
2015-01-13 19:41:20 +02:00
82ad7a9edb Added fixes for the case that BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS is defined.
[SVN r13684]
2015-01-13 19:41:20 +02:00
6a8080014a Integrated MSVC fixes from Daryle
[SVN r12012]
2015-01-13 19:41:19 +02:00
f6738d210c fix errors (from Daryle Walker)
[SVN r11935]
2015-01-13 19:41:19 +02:00
5f810b2754 Daryle Walker's GCD library submission
[SVN r11814]
2015-01-13 19:41:18 +02:00
163c26a2d4 Merge branch 'develop' 2015-01-13 18:44:48 +02:00
7c2b4a799d Merge pull request #5 from danieljames/metadata
Create metadata file.
2014-08-18 09:07:49 -07:00
dcfac1423f Add metadata file. 2014-08-18 14:59:48 +01:00
7d41c244ea Merge branch 'develop' 2014-06-08 01:38:20 +03:00
494f52d48e Remove obsolete boost/pending/cstddef.hpp. 2014-06-08 01:37:47 +03:00
40b52301df Move integer_log2 from pending to integer 2014-06-05 15:48:22 -07:00
e0ae3b54d8 Merge branch 'master' into develop 2014-06-05 15:32:01 -07:00
740a20e4bb Merge branch 'develop' 2014-06-05 15:31:45 -07:00
afa395b517 Merged changes from trunk that are going into 1.42.0
[SVN r58554]
2014-06-05 15:31:31 -07:00
78b9452696 boost/pending/: ported revision 48251 ("integer_log2.hpp and lowest_bit.hpp, in boost/pending/: little comment cleanup (svn anchors, etc.); added a static_cast<> to silence (harmless) MSVC++ warnings") from trunk
[SVN r48353]
2014-06-05 15:31:31 -07:00
775d25573b Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41369]
2014-06-05 15:31:31 -07:00
5328370ab6 Bring type traits into line with TR1
[SVN r26937]
2014-06-05 15:31:31 -07:00
a76279f48c added copyrights
[SVN r25809]
2014-06-05 15:31:31 -07:00
f71f747400 Converted to Boost Software License, Version 1.0
[SVN r24055]
2014-06-05 15:31:30 -07:00
70c7ae271c added Borland workaround
[SVN r22770]
2014-06-05 15:31:30 -07:00
ff18de3b35 new file (needed by dynamic_bitset)
[SVN r22651]
2014-06-05 15:31:30 -07:00
357349a423 Borland fix
[SVN r15360]
2014-06-05 15:31:30 -07:00
304cce63f5 ported the graph library to borland
[SVN r7965]
2014-06-05 15:31:30 -07:00
7ad2ddb3bc removed tabs
[SVN r7835]
2014-06-05 15:31:30 -07:00
ee352dee03 pending stuff from Boost Graph Library
[SVN r7704]
2014-06-05 15:31:30 -07:00
914b459763 boost/pending/: ported revision 48251 ("integer_log2.hpp and lowest_bit.hpp, in boost/pending/: little comment cleanup (svn anchors, etc.); added a static_cast<> to silence (harmless) MSVC++ warnings") from trunk
[SVN r48353]
2014-06-05 15:31:20 -07:00
0f7eb589da Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41369]
2014-06-05 15:31:20 -07:00
10e19f0e3e added Borland workaround
[SVN r22770]
2014-06-05 15:31:20 -07:00
1fd7a3080a new file (needed by dynamic_bitset)
[SVN r22651]
2014-06-05 15:31:20 -07:00
5c91a3c17c Merge branch 'develop' 2014-06-05 14:43:08 -07:00
0f228bcf5b Merge pull request #4 from danieljames/doc-clean-up
Documentation clean up
2014-06-02 01:38:29 -07:00
6ac4f9bdac Link to the cstdint documentation, rather than Boost.Config's root. 2014-06-02 09:28:38 +01:00
081eb01f88 Move cstdint section to the end.
So that it doesn't appear in the middle of documentation for things that
are in the library.
2014-06-02 09:28:38 +01:00
f43bd9288d Upgrade docs to quickbook 1.6.
Actually fixes a couple of errors where markup was used in table titles.
2014-06-02 09:28:38 +01:00
9b71d9e83f Add note about removing cstdint to history. 2014-06-02 09:28:38 +01:00
bb54ac650f Merge pull request #3 from glenfe/develop
Move cstdint out of Integer
2014-06-01 18:50:06 -07:00
05330d178e Remove cstdint which has been moved to Boost.Config 2014-06-01 10:52:52 -07:00
75134014bf Create merge base for git. 2014-04-06 14:07:51 +01:00
3f26103101 TypeTraits: Remove use of obsolete GCC version check.
[SVN r86060]
2013-09-30 15:55:29 +00:00
06c28356cc Merged recent changes from trunk.
[SVN r85088]
2013-07-20 17:17:10 +00:00
365d61fc4e Patch for recent versions of glibc which always assume int64_t support.
Fixes #8731.

[SVN r84950]
2013-07-04 09:13:23 +00:00
72438055a9 Extracted intptr_t and uintptr_t types to cstdint.hpp. Refs #7823.
[SVN r84805]
2013-06-16 15:02:27 +00:00
590f9819f9 Merge changes from trunk:
Fix PDF install rule so that it's explicit and automatically invokes a PDF build when specified on the command line.
So "bjam pdfinstall" will now build and install the PDF to the current directory.
This works around some problems that the previous versions had if the user did not have an FO processor installed (basically Daniel James was unable to build the HTML docs for the distribution if the pdfinstall rule was implicit).


[SVN r79500]
2012-07-14 16:05:50 +00:00
d131434ef1 Fix PDF install rule so that it's explicit and automatically invokes a PDF build when specified on the command line.
So "bjam pdfinstall" will now build and install the PDF to the current directory.
This works around some problems that the previous versions had if the user did not have an FO processor installed (basically Daniel James was unable to build the HTML docs for the distribution if the pdfinstall rule was implicit).

[SVN r79492]
2012-07-14 11:21:03 +00:00
d12ea4e301 Merge minor integer fixes from Trunk.
[SVN r78469]
2012-05-14 15:57:59 +00:00
90f779a9a3 Fix integer.hpp so a compiler error is generated when the number of bits requested is greater than the max available.
Added new tests to catch this case.

[SVN r78307]
2012-05-02 17:10:20 +00:00
1898e66238 Apply patch from Vincent Botet Escriba: fix check for size > long long.
[SVN r77109]
2012-02-24 16:57:13 +00:00
2f6544e54d Merge typo fixes from Trunk.
[SVN r76190]
2011-12-26 18:08:51 +00:00
cc73477d13 Fix typo.
Refs #6003.

[SVN r76137]
2011-12-24 17:29:03 +00:00
24785bf997 Merge [68802] from the trunk.
[SVN r70799]
2011-03-31 21:41:11 +00:00
8457bd01b1 Fix integer_traits<long long> when no macro from limits.h is available.
[SVN r68802]
2011-02-12 15:06:21 +00:00
707faa1086 Remove old dead code.
[SVN r68097]
2011-01-13 13:43:08 +00:00
614515a77b Fix logic in cstdint to prefer smaller integers when possible.
Improve PP-logic in integer-traits.
Suppress some compiler warnings.

[SVN r65721]
2010-10-02 12:14:04 +00:00
7bd48eb3f3 Change logic so that int32_t etc is an int rather than a long where possible.
[SVN r65299]
2010-09-05 16:27:09 +00:00
7c62277986 Add VMS support.
Fixes #4474.

[SVN r64750]
2010-08-12 12:36:42 +00:00
245c28d187 Merge integer documentation.
[SVN r63767]
2010-07-08 22:22:21 +00:00
8368cd0a55 Rebuild integer docs.
[SVN r63765]
2010-07-08 20:50:29 +00:00
f390a64825 Merge documentation fixes.
* Use `doc/src/*.css` instead of `doc/html/*.css`.
* Remove wiki and people directories.
* Some documentation fixes.
* Left out `minimal.css` changes and boostbook changes because of clashes.


[SVN r63347]
2010-06-26 12:30:09 +00:00
794fdf9bad Update various libraries' documentation build.
Mostly to use the images and css files under doc/src instead of
doc/html, usually be deleting the settings in order to use the defaults.
Also add 'boost.root' to some builds in order to fix links which rely on
it.

[SVN r63146]
2010-06-20 18:00:48 +00:00
e3da9260e1 Merge fixes from Trunk.
[SVN r62832]
2010-06-12 08:33:32 +00:00
cd98c4a257 Add a 64 bit specialization of low_bits_mask_t. Fixes #4332
[SVN r62756]
2010-06-10 19:49:34 +00:00
730be18188 Merge link fix for integer.
[SVN r61060]
2010-04-05 07:41:52 +00:00
84c8a52085 Rebuild the integer documentation.
[SVN r61058]
2010-04-05 07:27:25 +00:00
8a1d11f369 Fix link to integer header.
[SVN r59676]
2010-02-14 13:09:24 +00:00
a5356bb254 Change integer code to still work when BOOST_HAS_MS_INT64 is defined but BOOST_HAS_LONG_LONG is not.
Update VC++ config to define BOOST_HAS_LONG_LONG for MSVC-8 in ANSI mode.
Fixes #3657.

[SVN r59468]
2010-02-04 11:15:54 +00:00
2f13159023 Change code to check individually for the INT#_C macros before defining them - this correctly handles cases where they are partially defined by other other headers (for example ICU).
Also declare this a gcc system header - seems to be the only way to really suppress the warnings - fixes #3889.

[SVN r59430]
2010-02-02 18:35:33 +00:00
6293af825a Commit alternative warning suppression code.
[SVN r59264]
2010-01-25 10:55:50 +00:00
896f2a7654 Disable warnings when defining INT#_C macros for gcc.
[SVN r58948]
2010-01-12 18:51:40 +00:00
60db1676fc Merge both config and integer changes from Trunk: these are interlinked.
[SVN r58381]
2009-12-14 18:14:48 +00:00
e5c64669e2 Update docs to match code.
[SVN r58293]
2009-12-11 17:56:01 +00:00
14e17dd9f6 Update cstdint.hpp to always define the INT#_C macros.
Try again with Codegear workaround.

[SVN r58292]
2009-12-11 17:46:10 +00:00
86519e7bcf Extend codegear/borland fix.
[SVN r58291]
2009-12-11 15:59:42 +00:00
e5267abf6e Tentative Borland/Codegear patch.
[SVN r58113]
2009-12-03 12:14:15 +00:00
92a617bbe9 Get the tests warning free again with GCC.
Finally get everything working with the Borland compiler.
Fix a few typos: use of long rather than unsigned long, use of long long rather than long_long_type etc.

[SVN r58056]
2009-11-30 13:50:05 +00:00
ad5d5b0e1f Up template instantiation depth for sun compiler.
[SVN r58033]
2009-11-29 16:23:04 +00:00
3af7c55ad9 Make code respect BOOST_NO_INTEGRAL_INT64_T.
[SVN r58031]
2009-11-29 16:02:45 +00:00
1797528e35 Change long long to boost::long_long_type etc.
[SVN r58029]
2009-11-29 13:59:18 +00:00
05c1f88324 Fix issues in docs.
[SVN r58008]
2009-11-28 17:08:31 +00:00
6a497ee263 Regenerate with new stylesheets.
[SVN r57968]
2009-11-27 11:13:02 +00:00
98b57c1f3b Get the tests warning free with gcc, and add conceptual-header-inclusion tests.
[SVN r57948]
2009-11-26 18:06:10 +00:00
154b9ce992 Fix some typos.
[SVN r57946]
2009-11-26 15:43:32 +00:00
fad95e3d1f Oops, tests should return the error code is any.
[SVN r57943]
2009-11-26 13:35:03 +00:00
b83327861c Changed to use the lightweight test framework - we can now test with a much wider range of compilers.
[SVN r57942]
2009-11-26 12:59:39 +00:00
ac155d3843 Added support for exact width integer type to int_t and uint_t
Updated docs to match.
Fixes #1225.

[SVN r57941]
2009-11-26 11:08:27 +00:00
ca84baa55d Update Boost.Integer meta-programming classes to work with intmax_t where possible - ie to be 64-bit clean.
Added quickbook based docs - updated as necessary.
Removed old html docs.

[SVN r57926]
2009-11-25 12:38:09 +00:00
db267e22f8 Integer: fixed search&replace gone mad
[SVN r57908]
2009-11-24 21:24:20 +00:00
cf359129a3 Bring docs into line with code.
[SVN r57885]
2009-11-24 10:14:43 +00:00
09ee5872ba Tidied up namespace usage, fixes #2134.
[SVN r57884]
2009-11-24 10:12:29 +00:00
0248ecb71b Add history/revision log.
[SVN r57883]
2009-11-24 10:07:45 +00:00
ddb6a13f29 Add support for long long throughout.
Fixes #653.

[SVN r57873]
2009-11-23 18:51:33 +00:00
e07b49c955 remove reference to dead test (no longer relevant)
[SVN r57867]
2009-11-23 16:45:21 +00:00
44c3831e05 Fix Jamfile and Boost.Test usage.
[SVN r57866]
2009-11-23 16:39:45 +00:00
4c23c47ebe Add support for MS style __int64 when long long is not available.
Fixes #3084.

[SVN r57863]
2009-11-23 13:23:15 +00:00
285048504c Suppress and/or fix warnings - in particular avoid undefined behaviour in the test cases!
[SVN r57859]
2009-11-23 10:43:00 +00:00
8cab32a0dd Fix for Comeau compiler - does not define __GLIBC_HAVE_LONG_LONG which in turn causes GLIBC's stdint.h to misbehave.
Fixes #3548.

[SVN r57858]
2009-11-23 09:51:23 +00:00
9ff5c9d3b6 Fixes #3180.
[SVN r57845]
2009-11-22 17:12:57 +00:00
dd1194afa4 Fix preprocessor logic for long long support.
Fixes #3657.
Fixes #3568.

[SVN r57843]
2009-11-22 16:38:05 +00:00
eecbd5276f Reverted Integer back to Release branch state - as per devel-list discussions.
[SVN r57580]
2009-11-11 18:57:24 +00:00
fd0a8f8c2c Suppress gcc warnings: for bug report #1451.
[SVN r57170]
2009-10-27 09:58:40 +00:00
f9561fec20 rm cmake from trunk. I'm not entirely sure this is necessary to satisfy the inspect script, but I'm not taking any chances, and it is easy to put back
[SVN r56942]
2009-10-17 02:07:38 +00:00
be17e798df rm cmake from the release branch before it goes out broken. Policy dictates that you never commit to release, you commit to trunk and merge to release.
[SVN r56941]
2009-10-17 01:10:45 +00:00
9fd48f6a56 Copyrights on CMakeLists.txt to keep them from clogging up the inspect
reports.  This is essentially the same commit as r55095 on the release
branch.



[SVN r55159]
2009-07-26 00:49:56 +00:00
a1bf7131b3 Add basic copyright/license to keep cmake out of the inspection report
[SVN r55095]
2009-07-22 21:51:01 +00:00
dcdfca5f38 Use BOOST_STATIC_CONSTANT in static_log2, as g++ 4.0 has problems with enum.
Merged revisions 54811 via svnmerge from 
https://svn.boost.org/svn/boost/trunk


[SVN r54911]
2009-07-12 16:11:26 +00:00
edd638ec91 Use BOOST_STATIC_CONSTANT in static_log2, as g++ 4.0 has problems with enum.
[SVN r54811]
2009-07-08 21:27:05 +00:00
12e2311aa4 add missing #include to integer_mask_test.cpp
[SVN r50935]
2009-01-31 21:37:54 +00:00
e6bbb33660 merge of cmake build files from trunk per beman
[SVN r50756]
2009-01-24 18:57:20 +00:00
1b9549693a Merge from trunk
[SVN r50681]
2009-01-20 01:54:06 +00:00
382eabdff5 fixes #2654.
[SVN r50573]
2009-01-14 10:18:19 +00:00
3706ee7bd9 Fixes #2654.
[SVN r50572]
2009-01-14 10:17:25 +00:00
3531eb1ac5 merge tests and Jamfiles for 7 libraries
[SVN r50456]
2009-01-04 05:17:02 +00:00
ec8ede3378 Changed control of extra messages to be determined solely by the Boost.Test messaging controls
[SVN r50009]
2008-11-29 07:45:02 +00:00
a8f7c90aff Updating dependency information for modularized libraries.
[SVN r49628]
2008-11-07 17:05:27 +00:00
768023af1a Updating CMake files to latest trunk. Added dependency information for regression tests and a few new macros for internal use.
[SVN r49627]
2008-11-07 17:02:56 +00:00
c7e9da6551 Continuing merge of CMake build system files into trunk with the encouragement of Doug Gregor
[SVN r49510]
2008-11-01 13:15:41 +00:00
2d259a4f3e Added MPL-compatible variants of the integer-mask class templates (and finally make the lowest-bit-group metafunctions work for zero-length bit-groups)
[SVN r47869]
2008-07-29 19:33:20 +00:00
2fd0675a21 Hopefully made compile-time constants suitable for more compilers
[SVN r47852]
2008-07-28 14:41:00 +00:00
f041dc0f0a Added extended-integer support
[SVN r47842]
2008-07-27 17:08:51 +00:00
188cef05a9 Changed the Integer-mask test to use the unit-test system
[SVN r47841]
2008-07-27 16:34:38 +00:00
2ae867bcf8 Corrected link to corresponding test files
[SVN r47838]
2008-07-27 09:00:54 +00:00
2fcbc31b77 Tightened up code; number of bit-counts sampled is now comprehensive instead of representative (with a preprocessor switch for the old behavior since the new behavior greatly increases compile times)
[SVN r47801]
2008-07-25 12:39:06 +00:00
4af7660410 Encapsulated the mutually exclusive 'long long' and '__int64' type families into a single interface
[SVN r47754]
2008-07-24 11:43:02 +00:00
2b7ed6ebf7 Resolved namespace conflict from unadorned call, which fixes #2134
[SVN r47742]
2008-07-23 22:40:20 +00:00
203705fea6 Moved preprocessor selection from within macro-function calls to surrounding whole macro calls (some compilers suspend preprocessor directives within a macro call)
[SVN r47696]
2008-07-23 06:55:23 +00:00
ed80575830 Added MPL-compatible variants of the minimum-size and value-based integer templates, which fixes #1224
[SVN r47470]
2008-07-16 09:55:31 +00:00
f27ad7b337 Added MPL-compatible variant of the processor-optimized integer template
[SVN r47452]
2008-07-15 18:56:59 +00:00
55e1796c7a Added exact-integer templates, which fixes #1225 (and completes #653)
[SVN r47434]
2008-07-15 09:59:19 +00:00
053be71261 Added extended-integer support, which fixes #653 (the main part; the secondary part is split off as #1225)
[SVN r47414]
2008-07-14 06:28:54 +00:00
10e5587b9e Improved/added testing for the processor-optimized integer template
[SVN r47413]
2008-07-14 04:25:31 +00:00
2f91e69629 Re-did implementation
[SVN r47408]
2008-07-13 23:30:18 +00:00
422ef1ebe6 Replaced comprehensive macros with focused templates
[SVN r47404]
2008-07-13 21:08:16 +00:00
edfaeb6c0e Changed the Integer-selection test to use the unit-test system
[SVN r47200]
2008-07-07 23:13:43 +00:00
3c7910fad3 Added entries for the forgotten tests
[SVN r47123]
2008-07-06 00:58:34 +00:00
600801670e Move integer tests into canonical test subdir structure.
[SVN r44384]
2008-04-13 23:00:19 +00:00
85e4d3e23d Merged revisions 43206,43208-43213 via svnmerge from
https://svn.boost.org/svn/boost/trunk

........
  r43206 | danieljames | 2008-02-10 09:55:03 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Fix some broken links.
........
  r43209 | danieljames | 2008-02-10 14:56:22 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Link to people pages on the website, as they've been removed from the download.
........
  r43210 | danieljames | 2008-02-10 15:02:17 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Point links to the pages that used to be in 'more' to the site.
........
  r43212 | danieljames | 2008-02-10 16:10:16 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Fix links on the home page as well.
........
  r43213 | danieljames | 2008-02-10 16:21:22 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Generated documentation which is no longer generated.
........


[SVN r43214]
2008-02-10 16:39:38 +00:00
4e2c8440b5 Point links to the pages that used to be in 'more' to the site.
[SVN r43210]
2008-02-10 15:02:17 +00:00
94ace80618 Link to people pages on the website, as they've been removed from the download.
[SVN r43209]
2008-02-10 14:56:22 +00:00
550fe9d89f Merged revisions 43129,43131,43137,43139-43140,43142,43144,43146,43149,43151,43153,43158,43160-43164,43167-43170,43172-43174,43178,43180-43193 via svnmerge from
https://svn.boost.org/svn/boost/trunk

........
  r43129 | danieljames | 2008-02-06 19:02:38 +0000 (Wed, 06 Feb 2008) | 2 lines
  
  In the boostbook navbar, link FAQ and people to the website.
........
  r43188 | danieljames | 2008-02-09 12:29:02 +0000 (Sat, 09 Feb 2008) | 2 lines
  
  Fix a link in the intrusive redirect.
........
  r43189 | danieljames | 2008-02-09 12:37:00 +0000 (Sat, 09 Feb 2008) | 1 line
  
  Fix another redirect link.
........
  r43190 | danieljames | 2008-02-09 12:38:19 +0000 (Sat, 09 Feb 2008) | 1 line
  
  Update link to Jamfile, to link to the version 2 jamfile.
........
  r43191 | danieljames | 2008-02-09 12:39:06 +0000 (Sat, 09 Feb 2008) | 1 line
  
  Fix a link.
........
  r43192 | danieljames | 2008-02-09 12:45:32 +0000 (Sat, 09 Feb 2008) | 2 lines
  
  Add a forwarding header for hash/custom.html as Boost.Bimap links to it.
........
  r43193 | danieljames | 2008-02-09 13:02:45 +0000 (Sat, 09 Feb 2008) | 1 line
  
  Fix the link to the license.
........


[SVN r43194]
2008-02-09 13:27:00 +00:00
cd6a9565ff Fix the link to the license.
[SVN r43193]
2008-02-09 13:02:45 +00:00
19ed0e48e0 Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41370]
2007-11-25 18:38:02 +00:00
559b44c259 Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41369]
2007-11-25 18:07:19 +00:00
0d058f42cc Add missing copyright and license
[SVN r40835]
2007-11-06 13:41:19 +00:00
b162db6b72 Starting point for releases
[SVN r39706]
2007-10-05 14:25:06 +00:00
7d8e93a6ac Fixed comments listed in #766 that didn't match their described code
[SVN r39062]
2007-08-29 19:54:14 +00:00
4935afbcd4 This commit was manufactured by cvs2svn to create tag
'Version_1_34_1'.

[SVN r38286]
2007-07-24 19:28:14 +00:00
167961aba1 Correct testing bugs:
either changing assert(...) or BOOST_ASSERT(...) to BOOST_TEST
    (in my code only)

    or adding "return boost::report_errors();" where it was clearly
    missing (and a pure bug, in anyone's code).

    or changing BOOST_TEST to BOOST_CHECK where the integer library
    was clearly using Boost.Test and not returning report_errors().


[SVN r37063]
2007-02-25 15:28:02 +00:00
a1cc143de7 Added license to a person profile; updated license on Boost.Integer and Boost.IO doc files; changed 'BOOST_TEST' to 'BOOST_CHECK' on Boost.Integer testing *.cpp files
[SVN r35844]
2006-11-04 22:58:43 +00:00
7ce7ba6bfd Changed test to reflect changes made to C99 in the TC.
[SVN r35333]
2006-09-26 09:04:05 +00:00
cd99f24a87 Changed test to reflect changes made to C99 in the TC.
[SVN r35333]
2006-09-26 09:04:05 +00:00
c8cb2b24a1 This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'.
[SVN r33417]
2006-03-21 02:26:31 +00:00
93612e6c0b QNX does have a wchar.h and WCHAR_MAX/WCHAR_MIN even though there's not much else in it!
[SVN r32576]
2006-02-05 10:19:42 +00:00
d9f5b1bbf9 Apparently we forgot to include <limits.h>
[SVN r32397]
2006-01-24 17:23:54 +00:00
37d7590f2f Merged from Version_1_33_1
[SVN r31949]
2005-12-08 03:23:02 +00:00
cb9a7792cc Merge from RC_1_33_0.
[SVN r31703]
2005-11-19 19:38:13 +00:00
291bb8c525 Enable support for Dragonfly BSD
[SVN r30647]
2005-08-24 15:45:17 +00:00
8602a17a10 Replace buggy Cygwin INTMAX_C and UINTMAX_C macros
[SVN r29276]
2005-05-30 01:45:13 +00:00
29275d71aa added workaround for duplicate comdat errors in MSVC++ 6.0
[SVN r29186]
2005-05-25 13:43:12 +00:00
9df9a90217 Make PRIVATE_FIT_TESTS() work correctly on 64-bit machines.
[SVN r28779]
2005-05-10 08:40:28 +00:00
65607e3b82 Work around SunPro 5.3 issue
[SVN r28715]
2005-05-07 13:16:49 +00:00
39399de102 WCHAR_MIN is not trustworthy on MacOS X
[SVN r28714]
2005-05-07 13:14:07 +00:00
27aae3b3cb replaced BOOST_TEST
[SVN r27054]
2005-02-03 13:48:49 +00:00
21fe6251ab Fix to ensure that <wchar.h> is included on solaris (thanks to bug report by Caleb Epstein).
[SVN r26542]
2004-12-17 11:56:15 +00:00
07019a8801 Better support for Tru64.
[SVN r25689]
2004-10-12 16:42:58 +00:00
3892592661 c++boost.gif -> boost.png replacement
[SVN r25573]
2004-10-05 15:45:52 +00:00
0935f20c69 Added new types boost::long_long_type and boost::ulong_long_type in boost/config.hpp and applied these types in place of "long long" throughout. As a result, almost all of boost now compiles cleanly with -ansi -pedantic with gcc. Changes tested with gcc 3.3, 2.95, VC7.1 and Intel 8.
[SVN r24899]
2004-09-04 10:34:49 +00:00
7197caf500 Added Daryle Walker's copyrights as requested.
[SVN r24481]
2004-08-15 10:13:49 +00:00
92a46aac83 Removed boost.org copyright assignments, and reverted to orginal author (as based on cvs history).
[SVN r24402]
2004-08-11 10:59:33 +00:00
c32a045fa4 Removed Boost.org copyrights and replaced with originating authors copyright instead.
[SVN r24372]
2004-08-10 12:53:34 +00:00
0c31aa03f0 Don't #error when doing a release build. Just put out an informative message, and pass the test.
[SVN r24328]
2004-08-07 06:25:20 +00:00
bfc384a435 License update
[SVN r24180]
2004-07-30 04:46:56 +00:00
198530a48d Converted to Boost Software License, Version 1.0
[SVN r24096]
2004-07-27 03:43:34 +00:00
91f511cab4 Licence update
[SVN r24031]
2004-07-25 12:01:00 +00:00
0f84fe35da fixed typo in comment
[SVN r23945]
2004-07-22 09:02:43 +00:00
fa5aba353f - documented the new typedefs
- added a what's new section
- reformatted a bit
- updated license reference


[SVN r23944]
2004-07-22 08:57:45 +00:00
170a352574 new version - more efficient, and with no dependency on numeric_limits<>
[SVN r23829]
2004-07-20 09:49:43 +00:00
4862574bb1 remove minmax hack from win32.hpp and fix all places that could be affected by the minmax macros
[SVN r22394]
2004-02-26 18:27:02 +00:00
f2d22d091f Patches for cstdint support:
cygwin and mingw now use native stdint headers.
default header now compiles in -pedantic -ansi mode with gcc.


[SVN r21728]
2004-01-14 13:30:49 +00:00
1e6ab2dc10 index.htm renamed index.html
[SVN r21231]
2003-12-11 23:31:15 +00:00
a656e7744f Change license message to reference Boost Software License
[SVN r20038]
2003-09-12 17:09:29 +00:00
46fdbba4b8 Added NetBSD patches from Angus Leeming
[SVN r19804]
2003-08-27 10:30:53 +00:00
f2ea03679b Make sure to define __STDC_CONSTANT_MACROS before we include anything
[SVN r19747]
2003-08-23 13:21:30 +00:00
890e28ab67 include <boost/limits.hpp> instead of <limits.h>, fixing a date-time issue on Comeau
[SVN r18499]
2003-05-22 18:09:32 +00:00
1252426554 Added Cray X1 support
[SVN r17022]
2003-01-24 11:57:27 +00:00
19fb03cefe Added Cray support
[SVN r16989]
2003-01-22 12:12:14 +00:00
a9b35df2f8 add or update See www.boost.org comments
[SVN r16708]
2002-12-27 16:51:53 +00:00
49a8d69fe3 minor fix for integer_traits,
changed is_pod.hpp include to is_POD.hpp as a temporary fix


[SVN r15996]
2002-10-27 12:16:39 +00:00
9cc587a7f2 Merged changes from RC_1_29_0 branch
[SVN r15958]
2002-10-21 11:00:50 +00:00
2de1422682 boost/test/minimal.hpp
[SVN r15234]
2002-09-09 11:58:24 +00:00
66 changed files with 5204 additions and 2146 deletions

49
.drone.star Normal file
View File

@ -0,0 +1,49 @@
# Use, modification, and distribution are
# subject to the Boost Software License, Version 1.0. (See accompanying
# file LICENSE.txt)
#
# Copyright Rene Rivera 2020.
# For Drone CI we use the Starlark scripting language to reduce duplication.
# As the yaml syntax for Drone CI is rather limited.
#
#
globalenv={}
linuxglobalimage="cppalliance/droneubuntu1404:1"
windowsglobalimage="cppalliance/dronevs2019"
def main(ctx):
return [
linux_cxx("TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x Job 0", "g++", packages="g++-4.4", buildtype="boost", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.4', 'CXXSTD': '98,0x', 'DRONE_JOB_UUID': 'b6589fc6ab'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x Job 1", "g++", packages="g++-4.6", buildtype="boost", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.6', 'CXXSTD': '03,0x', 'DRONE_JOB_UUID': '356a192b79'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11 Job 2", "g++-4.7", packages="g++-4.7", buildtype="boost", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.7', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'da4b9237ba'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11 Job 3", "g++-4.8", packages="g++-4.8", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.8', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '77de68daec'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11 Job 4", "g++-4.9", packages="g++-4.9", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.9', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '1b64538924'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z Job 5", "g++-5", packages="g++-5", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-5', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'ac3478d69a'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z Job 6", "g++-6", packages="g++-6", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-6', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'c1dfd96eea'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 Job 7", "g++-7", packages="g++-7", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-7', 'CXXSTD': '03,11,14,17', 'DRONE_JOB_UUID': '902ba3cda1'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17 Job 8", "g++-8", packages="g++-8", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-8', 'CXXSTD': '03,11,14,17,2a', 'DRONE_JOB_UUID': 'fe5dbbcea5'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17 Job 9", "g++-9", packages="g++-9", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-9', 'CXXSTD': '03,11,14,17,2a', 'DRONE_JOB_UUID': '0ade7c2cf9'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,1 Job 10", "g++-10", packages="g++-10", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-10', 'CXXSTD': '03,11,14,17,20', 'DRONE_JOB_UUID': 'b1d5781111'}, globalenv=globalenv),
linux_cxx("UBSAN=1 TOOLSET=gcc COMPILER=g++-10 CXXSTD=03 Job 11", "g++-10", packages="g++-10", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'UBSAN': '1', 'TOOLSET': 'gcc', 'COMPILER': 'g++-10', 'CXXSTD': '03,11,14,17,20', 'UBSAN_OPTIONS': 'print_stacktrace=1', 'LINKFLAGS': '-fuse-ld=gold', 'DRONE_JOB_UUID': '17ba079149'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-3.4 CXXSTD=03, Job 12", "clang++", packages="clang-3.4 libstdc++-4.9-dev", llvm_os="trusty", llvm_ver="3.4", buildtype="boost", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.4', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '7b52009b64'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03, Job 13", "clang++", packages="clang-3.5 libstdc++-4.9-dev", llvm_os="trusty", llvm_ver="3.5", buildtype="boost", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.5', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'bd307a3ec3'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03, Job 14", "clang++", packages="clang-3.6 libstdc++-5-dev", llvm_os="trusty", llvm_ver="3.6", buildtype="boost", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.6', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'fa35e19212'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03, Job 15", "clang++", packages="clang-3.7 libstdc++-5-dev", llvm_os="trusty", llvm_ver="3.7", buildtype="boost", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.7', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'f1abd67035'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03, Job 16", "clang++-3.8", packages="clang-3.8 libstdc++-6-dev", llvm_os="xenial", llvm_ver="3.8", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.8', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '1574bddb75'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03, Job 17", "clang++-3.9", packages="clang-3.9 libstdc++-6-dev", llvm_os="xenial", llvm_ver="3.9", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.9', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '0716d9708d'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03, Job 18", "clang++-4.0", packages="clang-4.0 libstdc++-6-dev", llvm_os="xenial", llvm_ver="4.0", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-4.0', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '9e6a55b6b4'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03, Job 19", "clang++-5.0", packages="clang-5.0 libstdc++-7-dev", llvm_os="xenial", llvm_ver="5.0", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-5.0', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'b3f0c7f6bb'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03, Job 20", "clang++-6.0", packages="clang-6.0 libstdc++-8-dev", llvm_os="xenial", llvm_ver="6.0", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-6.0', 'CXXSTD': '03,11,14,17,2a', 'DRONE_JOB_UUID': '91032ad7bb'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11 Job 21", "clang++-7", packages="clang-7 libstdc++-8-dev", llvm_os="xenial", llvm_ver="7", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-7', 'CXXSTD': '03,11,14,17,2a', 'DRONE_JOB_UUID': '472b07b9fc'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11 Job 22", "clang++-8", packages="clang-8 libstdc++-8-dev", llvm_os="xenial", llvm_ver="8", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-8', 'CXXSTD': '03,11,14,17,2a', 'DRONE_JOB_UUID': '12c6fc06c9'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11 Job 23", "clang++-9", packages="clang-9 libstdc++-9-dev", llvm_os="xenial", llvm_ver="9", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-9', 'CXXSTD': '03,11,14,17,2a', 'DRONE_JOB_UUID': 'd435a6cdd7'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,1 Job 24", "clang++-10", packages="clang-10 libstdc++-9-dev", llvm_os="xenial", llvm_ver="10", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-10', 'CXXSTD': '03,11,14,17,20', 'DRONE_JOB_UUID': '4d134bc072'}, globalenv=globalenv),
linux_cxx("UBSAN=1 TOOLSET=clang COMPILER=clang++-10 CXX Job 25", "clang++-10", packages="clang-10 libstdc++-9-dev", llvm_os="xenial", llvm_ver="10", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'UBSAN': '1', 'TOOLSET': 'clang', 'COMPILER': 'clang++-10', 'CXXSTD': '03,11,14,17,20', 'UBSAN_OPTIONS': 'print_stacktrace=1', 'DRONE_JOB_UUID': 'f6e1126ced'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,1 Job 26", "clang++-10", packages="clang-10 libc++-10-dev libc++abi-10-dev", llvm_os="xenial", llvm_ver="10", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'CXXFLAGS': '-stdlib=libc++', 'LINKFLAGS': '-stdlib=libc++', 'TOOLSET': 'clang', 'COMPILER': 'clang++-10', 'CXXSTD': '03,11,14,17,20', 'DRONE_JOB_UUID': '887309d048'}, globalenv=globalenv),
linux_cxx("UBSAN=1 TOOLSET=clang COMPILER=clang++-10 CXX Job 27", "clang++-10", packages="clang-10 libc++-10-dev libc++abi-10-dev", llvm_os="xenial", llvm_ver="10", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'CXXFLAGS': '-stdlib=libc++', 'LINKFLAGS': '-stdlib=libc++', 'UBSAN': '1', 'TOOLSET': 'clang', 'COMPILER': 'clang++-10', 'CXXSTD': '03,11,14,17,20', 'UBSAN_OPTIONS': 'print_stacktrace=1', 'DRONE_JOB_UUID': 'bc33ea4e26'}, globalenv=globalenv),
osx_cxx("TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,1 Job 28", "clang++", packages="", buildtype="boost", xcode_version="11.2", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '03,11,14,17', 'DRONE_JOB_UUID': '0a57cb53ba'}, globalenv=globalenv),
]
# from https://github.com/boostorg/boost-ci
load("@boost_ci//ci/drone/:functions.star", "linux_cxx","windows_cxx","osx_cxx","freebsd_cxx")

3
.drone/after-success.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash

3
.drone/before-install.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash

3
.drone/before-script.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash

47
.drone/boost.sh Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
set -ex
export TRAVIS_BUILD_DIR=$(pwd)
export DRONE_BUILD_DIR=$(pwd)
export TRAVIS_BRANCH=$DRONE_BRANCH
export VCS_COMMIT_ID=$DRONE_COMMIT
export GIT_COMMIT=$DRONE_COMMIT
export REPO_NAME=$DRONE_REPO
export PATH=~/.local/bin:/usr/local/bin:$PATH
echo '==================================> BEFORE_INSTALL'
. .drone/before-install.sh
echo '==================================> INSTALL'
GIT_FETCH_JOBS=8
BOOST_BRANCH=develop
if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule init tools/boostdep
git submodule init tools/build
git submodule init tools/boost_install
git submodule init libs/headers
git submodule init libs/config
git submodule update --jobs $GIT_FETCH_JOBS
cp -r $TRAVIS_BUILD_DIR/* libs/integer
python tools/boostdep/depinst/depinst.py --git_args "--jobs $GIT_FETCH_JOBS" integer
./bootstrap.sh
./b2 headers
echo '==================================> BEFORE_SCRIPT'
. $DRONE_BUILD_DIR/.drone/before-script.sh
echo '==================================> SCRIPT'
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
BUILD_JOBS=`(nproc || sysctl -n hw.ncpu) 2> /dev/null`
./b2 -j $BUILD_JOBS libs/integer/test toolset=$TOOLSET cxxstd=$CXXSTD ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on visibility=global} ${CXXFLAGS:+cxxflags="$CXXFLAGS"} ${LINKFLAGS:+linkflags="$LINKFLAGS"}
echo '==================================> AFTER_SUCCESS'
. $DRONE_BUILD_DIR/.drone/after-success.sh

488
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,488 @@
# Copyright 2021-2023 Andrey Semashev
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
concurrency:
group: ${{format('{0}:{1}', github.repository, github.ref)}}
cancel-in-progress: true
env:
GIT_FETCH_JOBS: 8
NET_RETRY_COUNT: 5
DEFAULT_BUILD_VARIANT: debug,release
jobs:
posix:
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
# Linux, gcc
- toolset: gcc-4.6
cxxstd: "0x"
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.6
sources:
- "ppa:ubuntu-toolchain-r/test"
- toolset: gcc-4.7
cxxstd: "11"
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.7
- toolset: gcc-4.8
cxxstd: "11"
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-4.8
- toolset: gcc-4.9
cxxstd: "11"
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.9
- toolset: gcc-5
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-5
- toolset: gcc-6
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-6
- toolset: gcc-7
cxxstd: "11,14,17"
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-7
- toolset: gcc-8
cxxstd: "11,14,17,2a"
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-8
- toolset: gcc-9
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
install:
- g++-9
- toolset: gcc-10
cxxstd: "11,14,17,20"
os: ubuntu-20.04
install:
- g++-10
- toolset: gcc-11
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,23-gnu"
os: ubuntu-22.04
install:
- g++-11
- toolset: gcc-12
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,23-gnu"
os: ubuntu-22.04
install:
- g++-12
- name: UBSAN
toolset: gcc-11
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,23-gnu"
ubsan: 1
build_variant: debug
os: ubuntu-22.04
install:
- g++-11
# Linux, clang
- toolset: clang
compiler: clang++-3.5
cxxstd: "11"
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.5
- toolset: clang
compiler: clang++-3.6
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.6
- toolset: clang
compiler: clang++-3.7
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.7
- toolset: clang
compiler: clang++-3.8
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.8
- toolset: clang
compiler: clang++-3.9
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "11,14,17"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "11,14,17"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-7
# Note: clang-8 does not fully support C++20, so it is not compatible with libstdc++-8 in this mode
- toolset: clang
compiler: clang++-8
cxxstd: "11,14,17,2a"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-8
- g++-7
gcc_toolchain: 7
- toolset: clang
compiler: clang++-9
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
install:
- clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "11,14,17,20"
os: ubuntu-20.04
install:
- clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "11,14,17,20"
os: ubuntu-22.04
install:
- clang-11
- toolset: clang
compiler: clang++-12
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,2b-gnu"
os: ubuntu-22.04
install:
- clang-12
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-13
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,2b-gnu"
os: ubuntu-22.04
install:
- clang-13
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-14
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,2b-gnu"
os: ubuntu-22.04
install:
- clang-14
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-15
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,2b-gnu"
os: ubuntu-22.04
install:
- clang-15
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-15
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,2b-gnu"
os: ubuntu-22.04
install:
- clang-15
- libc++-15-dev
- libc++abi-15-dev
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
- toolset: clang
compiler: clang++-16
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,2b-gnu"
os: ubuntu-22.04
install:
- clang-16
sources:
- "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main"
source_keys:
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
- toolset: clang
compiler: clang++-16
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,2b-gnu"
os: ubuntu-22.04
install:
- clang-16
- libc++-16-dev
- libc++abi-16-dev
sources:
- "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main"
source_keys:
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
- name: UBSAN
toolset: clang
compiler: clang++-15
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,2b-gnu"
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
ubsan: 1
build_variant: debug
os: ubuntu-22.04
install:
- clang-15
- libc++-15-dev
- libc++abi-15-dev
- toolset: clang
cxxstd: "11,14,17,2a"
os: macos-11
timeout-minutes: 60
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
steps:
- name: Setup environment
run: |
if [ -f "/etc/debian_version" ]
then
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
export DEBIAN_FRONTEND=noninteractive
fi
if [ -n "${{matrix.container}}" ]
then
echo "GHA_CONTAINER=${{matrix.container}}" >> $GITHUB_ENV
if [ -f "/etc/debian_version" ]
then
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
if [ "$(apt-cache search "^python-is-python3$" | wc -l)" -ne 0 ]
then
PYTHON_PACKAGE="python-is-python3"
else
PYTHON_PACKAGE="python"
fi
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https ca-certificates make build-essential g++ $PYTHON_PACKAGE python3 perl git cmake
fi
fi
git config --global pack.threads 0
- uses: actions/checkout@v3
- name: Install packages
if: matrix.install
run: |
declare -a SOURCE_KEYS SOURCES
if [ -n "${{join(matrix.source_keys, ' ')}}" ]
then
SOURCE_KEYS=("${{join(matrix.source_keys, '" "')}}")
fi
if [ -n "${{join(matrix.sources, ' ')}}" ]
then
SOURCES=("${{join(matrix.sources, '" "')}}")
fi
for key in "${SOURCE_KEYS[@]}"
do
for i in {1..$NET_RETRY_COUNT}
do
echo "Adding key: $key"
wget -O - "$key" | sudo apt-key add - && break || sleep 2
done
done
if [ ${#SOURCES[@]} -gt 0 ]
then
APT_ADD_REPO_COMMON_ARGS=("-y")
APT_ADD_REPO_SUPPORTED_ARGS="$(apt-add-repository --help | perl -ne 'if (/^\s*-n/) { print "n"; } elsif (/^\s*-P/) { print "P"; } elsif (/^\s*-S/) { print "S"; } elsif (/^\s*-U/) { print "U"; }')"
if [ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*n*}" ]
then
APT_ADD_REPO_COMMON_ARGS+=("-n")
fi
APT_ADD_REPO_HAS_SOURCE_ARGS="$([ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*P*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*S*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*U*}" ] && echo 1 || echo 0)"
for source in "${SOURCES[@]}"
do
for i in {1..$NET_RETRY_COUNT}
do
APT_ADD_REPO_ARGS=("${APT_ADD_REPO_COMMON_ARGS[@]}")
if [ $APT_ADD_REPO_HAS_SOURCE_ARGS -ne 0 ]
then
case "$source" in
"ppa:"*)
APT_ADD_REPO_ARGS+=("-P")
;;
"deb "*)
APT_ADD_REPO_ARGS+=("-S")
;;
*)
APT_ADD_REPO_ARGS+=("-U")
;;
esac
fi
APT_ADD_REPO_ARGS+=("$source")
echo "apt-add-repository ${APT_ADD_REPO_ARGS[@]}"
sudo -E apt-add-repository "${APT_ADD_REPO_ARGS[@]}" && break || sleep 2
done
done
fi
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y ${{join(matrix.install, ' ')}}
- name: Setup GCC Toolchain
if: matrix.gcc_toolchain
run: |
GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain"
echo "GCC_TOOLCHAIN_ROOT=\"$GCC_TOOLCHAIN_ROOT\"" >> $GITHUB_ENV
MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
mkdir -p "$GCC_TOOLCHAIN_ROOT"
ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include"
ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin"
mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET"
ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}"
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
DEPINST_ARGS=()
GIT_VERSION="$(git --version | sed -e 's/git version //')"
GIT_HAS_JOBS=1
if [ -f "/etc/debian_version" ]
then
if $(dpkg --compare-versions "$GIT_VERSION" lt 2.8.0)
then
GIT_HAS_JOBS=0
fi
else
declare -a GIT_VER=(${GIT_VERSION//./ })
declare -a GIT_MIN_VER=(2 8 0)
for ((i=0; i<${#GIT_VER[@]}; i++))
do
if [ -z "${GIT_MIN_VER[i]}" ]
then
GIT_MIN_VER[i]=0
fi
if [ "${GIT_VER[i]}" -lt "${GIT_MIN_VER[i]}" ]
then
GIT_HAS_JOBS=0
break
fi
done
fi
if [ "$GIT_HAS_JOBS" -ne 0 ]
then
DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS")
fi
cd ..
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" "boost-root"
cd boost-root
mkdir -p libs/$LIBRARY
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
DEPINST_ARGS+=("$LIBRARY")
python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}"
if [ -z "${{matrix.cmake_tests}}" ]
then
./bootstrap.sh
./b2 headers
if [ -n "${{matrix.compiler}}" -o -n "$GCC_TOOLCHAIN_ROOT" ]
then
echo -n "using ${{matrix.toolset}} : : ${{matrix.compiler}}" > ~/user-config.jam
if [ -n "$GCC_TOOLCHAIN_ROOT" ]
then
echo -n " : <compileflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\" <linkflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\"" >> ~/user-config.jam
fi
echo " ;" >> ~/user-config.jam
fi
fi
- name: Run tests
if: matrix.cmake_tests == ''
run: |
cd ../boost-root
B2_ARGS=("-j" "$BUILD_JOBS" "toolset=${{matrix.toolset}}" "cxxstd=${{matrix.cxxstd}}")
if [ -n "${{matrix.build_variant}}" ]
then
B2_ARGS+=("variant=${{matrix.build_variant}}")
else
B2_ARGS+=("variant=$DEFAULT_BUILD_VARIANT")
fi
if [ -n "${{matrix.threading}}" ]
then
B2_ARGS+=("threading=${{matrix.threading}}")
fi
if [ -n "${{matrix.ubsan}}" ]
then
export UBSAN_OPTIONS="print_stacktrace=1"
B2_ARGS+=("cxxflags=-fsanitize=undefined -fno-sanitize-recover=undefined" "linkflags=-fsanitize=undefined -fuse-ld=gold" "define=UBSAN=1" "debug-symbols=on" "visibility=global")
fi
if [ -n "${{matrix.cxxflags}}" ]
then
B2_ARGS+=("cxxflags=${{matrix.cxxflags}}")
fi
if [ -n "${{matrix.linkflags}}" ]
then
B2_ARGS+=("linkflags=${{matrix.linkflags}}")
fi
B2_ARGS+=("libs/$LIBRARY/test")
./b2 "${B2_ARGS[@]}"

22
CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
# Copyright 2018 Peter Dimov
# Copyright 2018 Andrey Semashev
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.20)
project(boost_integer VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_integer INTERFACE)
add_library(Boost::integer ALIAS boost_integer)
target_include_directories(boost_integer INTERFACE include)
target_link_libraries(boost_integer
INTERFACE
Boost::assert
Boost::config
Boost::core
Boost::static_assert
Boost::throw_exception
)

32
README.md Normal file
View File

@ -0,0 +1,32 @@
# Boost.Integer
Boost.Integer, part of collection of the [Boost C++ Libraries](https://github.com/boostorg), provides
integer type support, particularly helpful in generic programming. It provides the means to select
an integer type based upon its properties, like the number of bits or the maximum supported value,
as well as compile-time bit mask selection. There is a derivative of `std::numeric_limits` that provides
integral constant expressions for `min` and `max`...
Finally, it provides two compile-time algorithms: determining the highest power of two in a
compile-time value; and computing min and max of constant expressions.
### Directories
* **doc** - QuickBook documentation sources
* **include** - Interface headers of Boost.Integer
* **test** - Boost.Integer unit tests
### More information
* [Documentation](https://boost.org/libs/integer)
* [Report bugs](https://github.com/boostorg/integer/issues/new). Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt).
### Build status
Branch | GitHub Actions | Drone | AppVeyor | Test Matrix | Dependencies |
:-------------: | -------------- | ----- | -------- | ----------- | ------------ |
[`master`](https://github.com/boostorg/integer/tree/master) | [![GitHub Actions](https://github.com/boostorg/integer/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/integer/actions?query=branch%3Amaster) | [![Drone](https://drone.cpp.al/api/badges/boostorg/integer/status.svg?ref=refs/heads/master)](https://drone.cpp.al/boostorg/integer) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/iugyf5rf51n99g3w/branch/master?svg=true)](https://ci.appveyor.com/project/Lastique/integer/branch/master) | [![Tests](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/integer.html) | [![Dependencies](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/integer.html)
[`develop`](https://github.com/boostorg/integer/tree/develop) | [![GitHub Actions](https://github.com/boostorg/integer/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/integer/actions?query=branch%3Adevelop) | [![Drone](https://drone.cpp.al/api/badges/boostorg/integer/status.svg?ref=refs/heads/develop)](https://drone.cpp.al/boostorg/integer) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/iugyf5rf51n99g3w/branch/develop?svg=true)](https://ci.appveyor.com/project/Lastique/integer/branch/develop) | [![Tests](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/integer.html) | [![Dependencies](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/integer.html)
### License
Distributed under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt).

82
appveyor.yml Normal file
View File

@ -0,0 +1,82 @@
# Copyright 2019 Andrey Semashev
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
- /feature\/.*/
environment:
matrix:
- TOOLSET: msvc-14.0
CXXSTD: 14,latest
ADDRMD: 32,64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: msvc-14.1
CXXSTD: 14,17,latest
ADDRMD: 32,64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- TOOLSET: msvc-14.2
ADDRMD: 32,64
CXXSTD: 14,17,20,latest
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- TOOLSET: msvc-14.3
ADDRMD: 32,64
CXXSTD: 14,17,20,latest
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
- TOOLSET: clang-win
ADDRMD: 32,64
CXXSTD: 14,17,latest
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- TOOLSET: gcc
CXXSTD: 11,14,1z
ADDPATH: C:\cygwin\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: gcc
CXXSTD: 11,14,1z
ADDPATH: C:\cygwin64\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: gcc
CXXSTD: 11,14,1z
ADDPATH: C:\mingw\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: gcc
CXXSTD: 11,14,1z
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: gcc
CXXSTD: 11,14,1z
ADDPATH: C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
install:
- set GIT_FETCH_JOBS=8
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- cd ..
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule init tools/build
- git submodule init tools/boostdep
- git submodule init tools/boost_install
- git submodule init libs/headers
- git submodule init libs/config
- git submodule update --jobs %GIT_FETCH_JOBS%
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\integer
- python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" integer
- cmd /c bootstrap
- b2 -d0 headers
build: off
test_script:
- PATH=%ADDPATH%%PATH%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- b2 -j %NUMBER_OF_PROCESSORS% libs/integer/test toolset=%TOOLSET% %CXXSTD% %ADDRMD%

View File

@ -1,78 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Header boost/cstdint.hpp</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" align="center" width="277" height="86">Header
boost/cstdint.hpp&nbsp;</h1>
<p>The header <code><a href="../../boost/cstdint.hpp">&lt;boost/cstdint.hpp&gt;</a></code>
provides the typedef's useful for
writing portable code that requires certain integer widths. All typedef's are in namespace boost.</p>
<p>The specifications are based on the ISO/IEC 9899:1999 C Language standard
header &lt;stdint.h&gt;.&nbsp; The 64-bit types required by the C standard are not
required in the boost header, and may not be supplied in all implementations,
because <code>long long</code> is not [yet] included in the C++ standard.</p>
<p>See <a href="cstdint_test.cpp">cstdint_test.cpp</a> for a test program.</p>
<h2>Exact-width integer types</h2>
<p>The typedef <code>int#_t</code>, with # replaced by the width, designates a
signed integer type of exactly # bits; <code>int8_t</code> denotes an 8-bit
signed integer type.&nbsp; Similarly, the typedef <code>uint#_t</code>
designates and unsigned integer type of exactly # bits.</p>
<p>These types are optional. However, if an implementation provides integer
types with widths of 8, 16, 32, or 64 bits, it shall define the corresponding
typedef names.</p>
<h2>Minimum-width integer types</h2>
<p>The typedef <code>int_least#_t</code>, with # replaced by the width,&nbsp;
designates a signed integer type with a width of at least # bits, such that no
signed integer type with lesser size has at least the specified width. Thus, <code>int_least32_t</code>
denotes a signed integer type with a width of at least 32 bits. Similarly, the
typedef name <code>uint_least#_t</code> designates an unsigned integer type with
a width of at least # bits, such that no unsigned integer type with lesser size
has at least the specified width.</p>
<p>Required minimum-width integer types:</p>
<ul>
<li><code>int_least8_t</code></li>
<li><code>int_least16_t</code></li>
<li><code>int_least32_t</code></li>
<li><code>uint_least8_t</code></li>
<li><code>uint_least16_t</code></li>
<li><code>uint_least32_t</code></li>
</ul>
<p>All other minimum-width integer types are optional.</p>
<h2>Fastest minimum-width integer types</h2>
<p>The typedef <code>int_fast#_t</code>, with # replaced by the width,
designates the fastest signed integer type with a width of at least # bits.
Similarly, the typedef name <code>uint_fast#_t</code> designates the fastest
unsigned integer type with a width of at least # bits.</p>
<p>There is no guarantee that these types are fastest for all purposes.&nbsp; In
any case, however, they satisfy&nbsp; the signedness and width requirements.</p>
<p>Required fastest minimum-width integer types:</p>
<ul>
<li><code>int_fast8_t</code></li>
<li><code>int_fast16_t</code></li>
<li><code>int_fast32_t</code></li>
<li><code>uint_fast8_t</code></li>
<li><code>uint_fast16_t</code></li>
<li><code>uint_fast32_t</code></li>
</ul>
<p>All other fastest minimum-width integer types are optional.</p>
<h2>Greatest-width integer types</h2>
<p>The typedef <code>intmax_t </code>designates a signed integer type capable of
representing any value of any signed integer type.</p>
<p>The typedef <code>uintmax_t</code> designates an unsigned integer type
capable of representing any value of any unsigned integer type.</p>
<p>These types are required.</p>
<hr>
<p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan -->19 Aug 2001<!--webbot bot="Timestamp" endspan i-checksum="14767" -->
</p>
<p>&nbsp;</p>
</body>
</html>

View File

@ -1,217 +0,0 @@
// boost cstdint.hpp test program ------------------------------------------//
// (C) Copyright Beman Dawes 2000. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 11 Sep 01 Adapted to work with macros defined in native stdint.h (John Maddock)
// 12 Nov 00 Adapted to merged <boost/cstdint.hpp>
// 23 Sep 00 Added INTXX_C constant macro support + int64_t support (John Maddock).
// 28 Jun 00 Initial version
#include <cassert>
#include <iostream>
#define __STDC_CONSTANT_MACROS
#include <boost/cstdint.hpp>
#ifdef NDEBUG
#error This test makes no sense with NDEBUG defined
#endif
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
//
// the following class is designed to verify
// that the various INTXX_C macros can be used
// in integral constant expressions:
//
struct integral_constant_checker
{
static const boost::int8_t int8 = INT8_C(-127);
static const boost::int_least8_t int_least8 = INT8_C(-127);
static const boost::int_fast8_t int_fast8 = INT8_C(-127);
static const boost::uint8_t uint8 = UINT8_C(255);
static const boost::uint_least8_t uint_least8 = UINT8_C(255);
static const boost::uint_fast8_t uint_fast8 = UINT8_C(255);
static const boost::int16_t int16 = INT16_C(-32767);
static const boost::int_least16_t int_least16 = INT16_C(-32767);
static const boost::int_fast16_t int_fast16 = INT16_C(-32767);
static const boost::uint16_t uint16 = UINT16_C(65535);
static const boost::uint_least16_t uint_least16 = UINT16_C(65535);
static const boost::uint_fast16_t uint_fast16 = UINT16_C(65535);
static const boost::int32_t int32 = INT32_C(-2147483647);
static const boost::int_least32_t int_least32 = INT32_C(-2147483647);
static const boost::int_fast32_t int_fast32 = INT32_C(-2147483647);
static const boost::uint32_t uint32 = UINT32_C(4294967295);
static const boost::uint_least32_t uint_least32 = UINT32_C(4294967295);
static const boost::uint_fast32_t uint_fast32 = UINT32_C(4294967295);
static void check();
};
void integral_constant_checker::check()
{
assert( int8 == -127 );
assert( int_least8 == -127 );
assert( int_fast8 == -127 );
assert( uint8 == 255u );
assert( uint_least8 == 255u );
assert( uint_fast8 == 255u );
assert( int16 == -32767 );
assert( int_least16 == -32767 );
assert( int_fast16 == -32767 );
assert( uint16 == 65535u );
assert( uint_least16 == 65535u );
assert( uint_fast16 == 65535u );
assert( int32 == -2147483647 );
assert( int_least32 == -2147483647 );
assert( int_fast32 == -2147483647 );
assert( uint32 == 4294967295u );
assert( uint_least32 == 4294967295u );
assert( uint_fast32 == 4294967295u );
}
#endif // BOOST_NO_INCLASS_MEMBER_INITIALIZATION
//
// the following function simply verifies that the type
// of an integral constant is correctly defined:
//
#ifdef __BORLANDC__
#pragma option -w-8008
#pragma option -w-8066
#endif
template <class T1, class T2>
void integral_constant_type_check(T1, T2)
{
//
// the types T1 and T2 may not be exactly
// the same type, but they should be the
// same size and signedness. We could use
// numeric_limits to verify this, but
// numeric_limits implementations currently
// vary too much, or are incomplete or missing.
//
T1 t1 = static_cast<T1>(-1); // cast suppresses warnings
T2 t2 = static_cast<T2>(-1); // ditto
#if defined(BOOST_HAS_STDINT_H)
// if we have a native stdint.h
// then the INTXX_C macros may define
// a type that's wider than required:
assert(sizeof(T1) <= sizeof(T2));
#else
assert(sizeof(T1) == sizeof(T2));
assert(t1 == t2);
#endif
if(t1 > 0)
assert(t2 > 0);
else
assert(!(t2 > 0));
}
int main()
{
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
integral_constant_checker::check();
#endif
//
// verify the types of the integral constants:
//
integral_constant_type_check(boost::int8_t(0), INT8_C(0));
integral_constant_type_check(boost::uint8_t(0), UINT8_C(0));
integral_constant_type_check(boost::int16_t(0), INT16_C(0));
integral_constant_type_check(boost::uint16_t(0), UINT16_C(0));
integral_constant_type_check(boost::int32_t(0), INT32_C(0));
integral_constant_type_check(boost::uint32_t(0), UINT32_C(0));
#ifndef BOOST_NO_INT64_T
integral_constant_type_check(boost::int64_t(0), INT64_C(0));
integral_constant_type_check(boost::uint64_t(0), UINT64_C(0));
#endif
//
boost::int8_t int8 = INT8_C(-127);
boost::int_least8_t int_least8 = INT8_C(-127);
boost::int_fast8_t int_fast8 = INT8_C(-127);
boost::uint8_t uint8 = UINT8_C(255);
boost::uint_least8_t uint_least8 = UINT8_C(255);
boost::uint_fast8_t uint_fast8 = UINT8_C(255);
boost::int16_t int16 = INT16_C(-32767);
boost::int_least16_t int_least16 = INT16_C(-32767);
boost::int_fast16_t int_fast16 = INT16_C(-32767);
boost::uint16_t uint16 = UINT16_C(65535);
boost::uint_least16_t uint_least16 = UINT16_C(65535);
boost::uint_fast16_t uint_fast16 = UINT16_C(65535);
boost::int32_t int32 = INT32_C(-2147483647);
boost::int_least32_t int_least32 = INT32_C(-2147483647);
boost::int_fast32_t int_fast32 = INT32_C(-2147483647);
boost::uint32_t uint32 = UINT32_C(4294967295);
boost::uint_least32_t uint_least32 = UINT32_C(4294967295);
boost::uint_fast32_t uint_fast32 = UINT32_C(4294967295);
#ifndef BOOST_NO_INT64_T
boost::int64_t int64 = INT64_C(-9223372036854775807);
boost::int_least64_t int_least64 = INT64_C(-9223372036854775807);
boost::int_fast64_t int_fast64 = INT64_C(-9223372036854775807);
boost::uint64_t uint64 = UINT64_C(18446744073709551615);
boost::uint_least64_t uint_least64 = UINT64_C(18446744073709551615);
boost::uint_fast64_t uint_fast64 = UINT64_C(18446744073709551615);
boost::intmax_t intmax = INTMAX_C(-9223372036854775807);
boost::uintmax_t uintmax = UINTMAX_C(18446744073709551615);
#else
boost::intmax_t intmax = INTMAX_C(-2147483647);
boost::uintmax_t uintmax = UINTMAX_C(4294967295);
#endif
assert( int8 == -127 );
assert( int_least8 == -127 );
assert( int_fast8 == -127 );
assert( uint8 == 255u );
assert( uint_least8 == 255u );
assert( uint_fast8 == 255u );
assert( int16 == -32767 );
assert( int_least16 == -32767 );
assert( int_fast16 == -32767 );
assert( uint16 == 65535u );
assert( uint_least16 == 65535u );
assert( uint_fast16 == 65535u );
assert( int32 == -2147483647 );
assert( int_least32 == -2147483647 );
assert( int_fast32 == -2147483647 );
assert( uint32 == 4294967295u );
assert( uint_least32 == 4294967295u );
assert( uint_fast32 == 4294967295u );
#ifndef BOOST_NO_INT64_T
assert( int64 == INT64_C(-9223372036854775807) );
assert( int_least64 == INT64_C(-9223372036854775807) );
assert( int_fast64 == INT64_C(-9223372036854775807) );
assert( uint64 == UINT64_C(18446744073709551615) );
assert( uint_least64 == UINT64_C(18446744073709551615) );
assert( uint_fast64 == UINT64_C(18446744073709551615) );
assert( intmax == INT64_C(-9223372036854775807) );
assert( uintmax == UINT64_C(18446744073709551615) );
#else
assert( intmax == -2147483647 );
assert( uintmax == 4294967295u );
#endif
std::cout << "OK\n";
return 0;
}

60
doc/Jamfile.v2 Normal file
View File

@ -0,0 +1,60 @@
# Copyright John Maddock 2005. Use, modification, and distribution are
# subject to the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
using quickbook ;
xml integer : integer.qbk ;
boostbook standalone
:
integer
:
# HTML options first:
# Use graphics not text for navigation:
<xsl:param>navig.graphics=1
# How far down we chunk nested sections, basically all of them:
<xsl:param>chunk.section.depth=1
# Don't put the first section on the same page as the TOC:
<xsl:param>chunk.first.sections=0
# How far down sections get TOC's
<xsl:param>toc.section.depth=1
# Max depth in each TOC:
<xsl:param>toc.max.depth=1
# How far down we go with TOC's
<xsl:param>generate.section.toc.level=4
# Path for links to Boost:
<xsl:param>"boost.root=../../../.."
# PDF Options:
# TOC Generation: this is needed for FOP-0.9 and later:
<xsl:param>fop1.extensions=0
# Or enable this if you're using XEP:
<xsl:param>xep.extensions=1
# TOC generation: this is needed for FOP 0.2, but must not be set to zero for FOP-0.9!
<xsl:param>fop.extensions=0
# No indent on body text:
<xsl:param>body.start.indent=0pt
# Margin size:
<xsl:param>page.margin.inner=0.5in
# Margin size:
<xsl:param>page.margin.outer=0.5in
# Yes, we want graphics for admonishments:
<xsl:param>admon.graphics=1
# Set this one for PDF generation *only*:
# default pnd graphics are awful in PDF form,
# better use SVG's instead:
<format>pdf:<xsl:param>admon.graphics.extension=".svg"
<format>pdf:<xsl:param>"admon.graphics.path=$(boost-images)/"
<format>pdf:<xsl:param>"boost.url.prefix=https://www.boost.org/doc/libs/release/libs/integer/doc/html"
;
install pdfinstall : standalone/<format>pdf : <location>. <install-type>PDF ;
explicit pdfinstall ;
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : standalone ;
explicit boostrelease ;

290
doc/gcd/math-gcd.qbk Normal file
View File

@ -0,0 +1,290 @@
[section:gcd_lcm Greatest Common Divisor and Least Common Multiple]
[section Introduction]
The class and function templates in <boost/math/common_factor.hpp>
provide run-time and compile-time evaluation of the greatest common divisor
(GCD) or least common multiple (LCM) of two integers.
These facilities are useful for many numeric-oriented generic
programming problems.
[endsect]
[section Synopsis]
namespace boost
{
namespace integer
{
template < typename IntegerType >
class gcd_evaluator;
template < typename IntegerType >
class lcm_evaluator;
template < typename IntegerType >
constexpr IntegerType gcd( IntegerType const &a, IntegerType const &b );
template < typename IntegerType >
constexpr IntegerType lcm( IntegerType const &a, IntegerType const &b );
template < typename IntegerType, typename... Args >
constexpr IntegerType gcd( IntegerType const &a, IntegerType const &b, Args const&... );
template < typename IntegerType, typename... Args >
constexpr IntegerType lcm( IntegerType const &a, IntegerType const &b, Args const&... );
template <typename I>
std::pair<typename std::iterator_traits<I>::value_type, I>
gcd_range(I first, I last);
template <typename I>
std::pair<typename std::iterator_traits<I>::value_type, I>
lcm_range(I first, I last);
typedef ``['see-below]`` static_gcd_type;
template < static_gcd_type Value1, static_gcd_type Value2 >
struct static_gcd;
template < static_gcd_type Value1, static_gcd_type Value2 >
struct static_lcm;
}
}
[endsect]
[section GCD Function Object]
[*Header: ] [@../../../../boost/integer/common_factor_rt.hpp <boost/integer/common_factor_rt.hpp>]
template < typename IntegerType >
class boost::integer::gcd_evaluator
{
public:
// Types
typedef IntegerType result_type;
typedef IntegerType first_argument_type;
typedef IntegerType second_argument_type;
// Function object interface
constexpr result_type operator ()(
first_argument_type const &a,
second_argument_type const &b ) const;
};
The boost::integer::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.
Note that these function objects are `constexpr` in C++14 and later only.
They are also declared `noexcept` when appropriate.
[endsect]
[section LCM Function Object]
[*Header: ] [@../../../../boost/integer/common_factor_rt.hpp <boost/integer/common_factor_rt.hpp>]
template < typename IntegerType >
class boost::integer::lcm_evaluator
{
public:
// Types
typedef IntegerType result_type;
typedef IntegerType first_argument_type;
typedef IntegerType second_argument_type;
// Function object interface
constexpr result_type operator ()(
first_argument_type const &a,
second_argument_type const &b ) const;
};
The boost::integer::lcm_evaluator class template defines a function object
class to return the least common multiple 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. If the least common multiple is beyond the range
of the integer type, the results are undefined.
This function object class template is used in the corresponding version
of the LCM function template. If a numeric type wants to customize
evaluations of its least common multiples, then the type should
specialize on the lcm_evaluator class template.
Note that these function objects are constexpr in C++14 and later only.
They are also declared `noexcept` when appropriate.
[endsect]
[section:run_time Run-time GCD & LCM Determination]
[*Header: ] [@../../../../boost/integer/common_factor_rt.hpp <boost/integer/common_factor_rt.hpp>]
template < typename IntegerType >
constexpr IntegerType boost::integer::gcd( IntegerType const &a, IntegerType const &b );
template < typename IntegerType >
constexpr IntegerType boost::integer::lcm( IntegerType const &a, IntegerType const &b );
template < typename IntegerType, typename... Args >
constexpr IntegerType gcd( IntegerType const &a, IntegerType const &b, Args const&... );
template < typename IntegerType, typename... Args >
constexpr IntegerType lcm( IntegerType const &a, IntegerType const &b, Args const&... );
template <typename I>
std::pair<typename std::iterator_traits<I>::value_type, I>
gcd_range(I first, I last);
template <typename I>
std::pair<typename std::iterator_traits<I>::value_type, I>
lcm_range(I first, I last);
The boost::integer::gcd function template returns the greatest common
(nonnegative) divisor of the two integers passed to it.
`boost::integer::gcd_range` is the iteration of the above gcd algorithm over a
range, returning the greatest common divisor of all the elements. The algorithm
terminates when the gcd reaches unity or the end of the range. Thus it also
returns the iterator after the last element inspected because this may not be
equal to the end of the range. The variadic version of `gcd` behaves similarly
but does not indicate which input value caused the gcd to reach unity.
The boost::integer::lcm function template returns the least common
(nonnegative) multiple of the two integers passed to it.
As with gcd, there are range and variadic versions of the function for
more than 2 arguments.
Note that these functions are constexpr in C++14 and later only.
They are also declared `noexcept` when appropriate.
[endsect]
[section:compile_time Compile time GCD and LCM determination]
[note These functions are deprecated in favor of constexpr `gcd` and `lcm` on C++14 capable compilers.]
[*Header: ] [@../../../../boost/integer/common_factor_ct.hpp <boost/integer/common_factor_ct.hpp>]
typedef ``['unspecified]`` static_gcd_type;
template < static_gcd_type Value1, static_gcd_type Value2 >
struct boost::integer::static_gcd : public mpl::integral_c<static_gcd_type, implementation_defined>
{
};
template < static_gcd_type Value1, static_gcd_type Value2 >
struct boost::integer::static_lcm : public mpl::integral_c<static_gcd_type, implementation_defined>
{
};
The type `static_gcd_type` is the widest unsigned-integer-type that is supported
for use in integral-constant-expressions by the compiler. Usually this
the same type as `boost::uintmax_t`, but may fall back to being `unsigned long`
for some older compilers.
The boost::integer::static_gcd and boost::integer::static_lcm class templates
take two value-based template parameters of the ['static_gcd_type] type
and inherit from the type `boost::mpl::integral_c`.
Inherited from the base class, they have a member /value/
that is the greatest common factor or least
common multiple, respectively, of the template arguments.
A compile-time error will occur if the least common multiple
is beyond the range of `static_gcd_type`.
[h3 Example]
#include <boost/integer/common_factor.hpp>
#include <algorithm>
#include <iterator>
#include <iostream>
int main()
{
using std::cout;
using std::endl;
cout << "The GCD and LCM of 6 and 15 are "
<< boost::integer::gcd(6, 15) << " and "
<< boost::integer::lcm(6, 15) << ", respectively."
<< endl;
cout << "The GCD and LCM of 8 and 9 are "
<< boost::integer::static_gcd<8, 9>::value
<< " and "
<< boost::integer::static_lcm<8, 9>::value
<< ", respectively." << endl;
int a[] = { 4, 5, 6 }, b[] = { 7, 8, 9 }, c[3];
std::transform( a, a + 3, b, c, boost::integer::gcd_evaluator<int>() );
std::copy( c, c + 3, std::ostream_iterator<int>(cout, " ") );
}
[endsect]
[section:gcd_header Header <boost/integer/common_factor.hpp>]
This header simply includes the headers
[@../../../../boost/integer/common_factor_ct.hpp <boost/integer/common_factor_ct.hpp>]
and [@../../../../boost/integer/common_factor_rt.hpp <boost/integer/common_factor_rt.hpp>].
Note this is a legacy header: it used to contain the actual implementation,
but the compile-time and run-time facilities
were moved to separate headers (since they were independent of each other).
[endsect]
[section:demo Demonstration Program]
The program [@../../../../libs/integer/test/common_factor_test.cpp common_factor_test.cpp] is a demonstration of the results from
instantiating various examples of the run-time GCD and LCM function
templates and the compile-time GCD and LCM class templates.
(The run-time GCD and LCM class templates are tested indirectly through
the run-time function templates.)
[endsect]
[section Rationale]
The greatest common divisor and least common multiple functions are
greatly used in some numeric contexts, including some of the other
Boost libraries. Centralizing these functions to one header improves
code factoring and eases maintenance.
[endsect]
[section:gcd_history History]
* 24th April 2017 Moved to Jeremy Murphy's improved algorithms, added constexpr and noexcept support,
added compiler intrinsic support, added variadic and range based versions of the algorithms.
* 13 May 2013 Moved into main Boost.Math Quickbook documentation.
* 17 Dec 2005: Converted documentation to Quickbook Format.
* 2 Jul 2002: Compile-time and run-time items separated to new headers.
* 7 Nov 2001: Initial version
[endsect]
[section:gcd_credits Credits]
The author of the Boost compilation of GCD and LCM computations is
Daryle Walker. The code was prompted by existing code hiding in the
implementations of Paul Moore's rational library and Steve Cleary's
pool library. The code had updates by Helmut Zeisel.
[endsect]
[endsect]
[/
Copyright 2005, 2013 Daryle Walker.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
https://www.boost.org/LICENSE_1_0.txt).
]

724
doc/integer.qbk Normal file
View File

@ -0,0 +1,724 @@
[article Boost.Integer
[quickbook 1.6]
[compatibility-mode 1.5]
[copyright 2001-2009 Beman Dawes, Daryle Walker, Gennaro Prota, John Maddock]
[license
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
[@https://www.boost.org/LICENSE_1_0.txt])
]
[authors [Dawes, Beman], [Walker, Daryle], [Prota, Gennaro], [Maddock, John]]
[/last-revision $Date: 2008-02-21 12:58:15 +0000 (Thu, 21 Feb 2008) $]
]
[template super[x]'''<superscript>'''[x]'''</superscript>''']
[section:overview Overview]
Boost.Integer provides integer type support, particularly helpful in generic programming.
It provides the means to select an integer type based upon its properties, like the number of bits or
the maximum supported value, as well as compile-time bit mask selection. There is a derivative of
std::numeric_limits that provides integral constant expressions for `min` and `max`.
Finally, it provides two compile-time algorithms: determining the highest power of two in a
compile-time value; and computing min and max of constant expressions.
[table
[[Component][Header][Purpose]]
[
[Forward Declarations.]
[[^[@../../../../boost/integer_fwd.hpp <boost/integer_fwd.hpp>]]]
[Forward declarations of classes and class templates - for use when just the name of a class is needed.]
]
[
[[link boost_integer.traits Integer Traits].]
[[^[@../../../../boost/integer_traits.hpp <boost/integer_traits.hpp>]]]
[Class template [^boost::integer_traits], derives from [^std::numeric_limits] and adds [^const_min] and [^const_max] members.]
]
[
[[link boost_integer.integer Integer Type Selection].]
[[^[@../../../../boost/integer.hpp <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. ]
]
[
[[link boost_integer.gcd_lcm Greatest Common Divisor and Least Common Multiple].]
[[^[@../../../../boost/integer/common_factor_rt.hpp <boost/integer/common_factor_rt.hpp>]] and [^[@../../../../boost/integer/common_factor_ct.hpp <boost/integer/common_factor_ct.hpp>]]]
[Functions `gcd` and `lcm` plus function objects and compile time versions.]
]
[
[[link boost_integer.mask Integer Masks].]
[[^[@../../../../boost/integer/integer_mask.hpp <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. ]
]
[
[[link boost_integer.log2 Compile time log2 Calculation].]
[[^[@../../../../boost/integer/static_log2.hpp <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. ]
]
[
[[link boost_integer.minmax Compile time min/max calculation].]
[[^[@../../../../boost/integer/static_min_max.hpp <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. ]
]
[
[[link boost_integer.extended_euclidean Extended Euclidean algorithm].]
[[^[@../../../../boost/integer/extended_euclidean.hpp <boost/integer/extended_euclidean.hpp>]]]
[Solves /mx + ny = gcd(x,y)/ for /x/ and /y/.]
]
[
[[link boost_integer.mod_inverse Modular multiplicative inverse].]
[[^[@../../../../boost/integer/mod_inverse.hpp <boost/integer/mod_inverse.hpp>]]]
[Given /a/ and /m/, solves /ax/ = 1 mod /m/ for /x/.]
]
]
[endsect]
[section:traits Integer Traits]
[section Motivation]
The C++ Standard Library <limits> header supplies a class template `numeric_limits<>` with specializations for each fundamental type.
For integer types, the interesting members of `std::numeric_limits<>` are:
static const bool is_specialized; // Will be true for integer types.
static T min() throw(); // Smallest representable value.
static T max() throw(); // Largest representable value.
static const int digits; // For integers, the number of value bits.
static const int digits10; // The number of base 10 digits that can be represented.
static const bool is_signed; // True if the type is signed.
static const bool is_integer; // Will be true for all integer types.
For many uses, these are sufficient.
But min() and max() are problematical because they are not constant expressions (std::5.19),
yet some usages require constant expressions.
The template class [^integer_traits] addresses this problem.
[endsect]
[section Synopsis]
namespace boost {
template<class T>
class integer_traits : public std::numeric_limits<T>
{
public:
static const bool is_integral = false;
//
// These members are defined only if T is a built-in
// integal type:
//
static const T const_min = ``['implementation-defined]``;
static const T const_max = ``['implementation-defined]``;
};
}
[endsect]
[section Description]
Template class [^integer_traits] is derived from [^std::numeric_limits]. The primary specialization adds the single
[^bool] member [^is_integral] with the compile-time constant value [^false].
However, for all integral types [^T] (std::3.9.1/7 [basic.fundamental]), there are specializations
provided with the following compile-time constants defined:
[table
[[member][type][value]]
[[[^is_integral]][bool][[^true]]]
[[[^const_min]][[^T]][equivalent to [^std::numeric_limits<T>::min()]]]
[[[^const_max]][[^T]][equivalent to [^std::numeric_limits<T>::max()]]]
]
Note: The /is_integral/ flag is provided, because a user-defined integer class should specialize
[^std::numeric_limits<>::is_integer = true], while compile-time constants
[^const_min] and [^const_max] are not provided for that user-defined class, unless boost::integer_traits is also specialized.
[endsect]
[section Test Program]
The program [^[@../../test/integer_traits_test.cpp integer_traits_test.cpp]] exercises the [^integer_traits] class.
[endsect]
[section Acknowledgements]
Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers discussed the integer traits idea on the boost mailing list in August 1999.
[endsect]
[endsect]
[section:integer Integer Type Selection]
The [@../../../../boost/integer.hpp <boost/integer.hpp>] type selection templates allow
integer types to be selected based on desired characteristics such as number of bits or maximum value.
This facility is particularly useful for solving generic programming problems.
[section:synopsis Synopsis]
namespace boost
{
// fast integers from least integers
template<typename LeastInt>
struct int_fast_t
{
typedef ``['implementation-defined-type]`` type;
};
// signed
template<int Bits>
struct int_t
{
/* Member exact may or may not be defined depending upon Bits */
typedef ``['implementation-defined-type]`` exact;
typedef ``['implementation-defined-type]`` least;
typedef int_fast_t<least>::fast fast;
};
// unsigned
template<int Bits>
struct uint_t
{
/* Member exact may or may not be defined depending upon Bits */
typedef ``['implementation-defined-type]`` exact;
typedef ``['implementation-defined-type]`` least;
typedef int_fast_t<least>::fast fast;
};
// signed
template<long long MaxValue>
struct int_max_value_t
{
typedef ``['implementation-defined-type]`` least;
typedef int_fast_t<least>::fast fast;
};
template<long long MinValue>
struct int_min_value_t
{
typedef ``['implementation-defined-type]`` least;
typedef int_fast_t<least>::fast fast;
};
// unsigned
template<unsigned long long Value>
struct uint_value_t
{
typedef ``['implementation-defined-type]`` least;
typedef int_fast_t<least>::fast fast;
};
} // namespace boost
[endsect]
[section:easiest Easiest-to-Manipulate Types]
The [^int_fast_t] class template maps its input type to the next-largest type that the processor
can manipulate the easiest, or to itself if the input type is already an easy-to-manipulate type.
For instance, processing a bunch of [^char] objects may go faster if they were converted to [^int] objects before processing.
The input type, passed as the only template parameter, must be a built-in integral type, except [^bool].
Unsigned integral types can be used, as well as signed integral types.
The output type is given as the nested type [^fast].
[*Implementation Notes:]
By default, the output type is identical to the input type. Eventually, this code's implementation should
be customized for each platform to give accurate mappings between the built-in types and the easiest-to-manipulate
built-in types. Also, there is no guarantee that the output type actually is easier to manipulate than the input type.
[endsect]
[section:sized Sized Types]
The [^int_t], [^uint_t], [^int_max_value_t], [^int_min_value_t], and [^uint_value_t] class templates find
the most appropiate built-in integral type for the given template parameter. This type is given by the
nested type [^least]. The easiest-to-manipulate version of that type is given by the nested type [^fast].
The following table describes each template's criteria.
[table Criteria for the Sized Type Class Templates
[
[Class Template][Template Parameter Mapping]
]
[
[[^boost::int_t<N>::least]]
[The smallest, built-in, signed integral type with at least /N/ bits, including the sign bit.
The parameter should be a positive number. A compile-time error results if the parameter is
larger than the number of bits in the largest integer type.]
]
[
[[^boost::int_t<N>::fast]]
[The easiest-to-manipulate, built-in, signed integral type with at least /N/ bits, including the sign bit.
The parameter should be a positive number. A compile-time error results if the parameter is
larger than the number of bits in the largest integer type.]
]
[
[[^boost::int_t<N>::exact]]
[A built-in, signed integral type with exactly /N/ bits, including the sign bit.
The parameter should be a positive number. Note that the member /exact/ is defined
[*only] if there exists a type with exactly /N/ bits.]
]
[
[[^boost::uint_t<N>::least]]
[The smallest, built-in, unsigned integral type with at least /N/ bits.
The parameter should be a positive number. A compile-time error results if the
parameter is larger than the number of bits in the largest integer type.]
]
[
[[^boost::uint_t<N>::fast]]
[The easiest-to-manipulate, built-in, unsigned integral type with at least /N/ bits.
The parameter should be a positive number. A compile-time error results if the
parameter is larger than the number of bits in the largest integer type.]
]
[
[[^boost::uint_t<N>::exact]]
[A built-in, unsigned integral type with exactly /N/ bits.
The parameter should be a positive number. A compile-time error results if the
parameter is larger than the number of bits in the largest integer type.
Note that the member /exact/ is defined
[*only] if there exists a type with exactly N bits.]
]
[
[[^boost::int_max_value_t<V>::least]]
[The smallest, built-in, signed integral type that can hold all the values in the inclusive range ['0 - V].
The parameter should be a positive number.]
]
[
[[^boost::int_max_value_t<V>::fast]]
[The easiest-to-manipulate, built-in, signed integral type that can hold all the values in the inclusive range ['0 - V].
The parameter should be a positive number.]
]
[
[[^boost::int_min_value_t<V>::least]]
[The smallest, built-in, signed integral type that can hold all the values in the inclusive range ['V - 0].
The parameter should be a negative number.]
]
[
[[^boost::int_min_value_t<V>::fast]]
[The easiest-to-manipulate, built-in, signed integral type that can hold all the values in the inclusive range ['V - 0].
The parameter should be a negative number.]
]
[
[[^boost::uint_value_t<V>::least]]
[The smallest, built-in, unsigned integral type that can hold all positive values
up to and including /V/. The parameter should be a positive number.]
]
[
[[^boost::uint_value_t<V>::fast]]
[The easiest-to-manipulate, built-in, unsigned integral type that can hold all positive values
up to and including /V/. The parameter should be a positive number.]
]
]
[endsect]
[section Example]
#include <boost/integer.hpp>
//...
int main()
{
boost::int_t<24>::least my_var; // my_var has at least 24-bits
//...
// This one is guaranteed not to be truncated:
boost::int_max_value_t<1000>::least my1000 = 1000;
//...
// This one is guaranteed not to be truncated, and as fast
// to manipulate as possible, its size may be greater than
// that of my1000:
boost::int_max_value_t<1000>::fast my_fast1000 = 1000;
}
[endsect]
[section Demonstration Program]
The program [@../../test/integer_test.cpp integer_test.cpp] is a simplistic demonstration of the results from instantiating
various examples of the sized type class templates.
[endsect]
[section Rationale]
The rationale for the design of the templates in this header includes:
* Avoid recursion because of concern about C++'s limited guaranteed recursion depth (17).
* Avoid macros on general principles.
* Try to keep the design as simple as possible.
[endsect]
[section Alternative]
If the number of bits required is known beforehand, it may be more appropriate to use the types supplied
in [@../../../../boost/cstdint.hpp <boost/cstdint.hpp>].
[endsect]
[section Credits]
The author of most of the Boost integer type choosing templates is
[@https://www.boost.org/people/beman_dawes.html Beman Dawes].
He gives thanks to Valentin Bonnard and [@https://www.boost.org/people/kevlin_henney.htm Kevlin Henney]
for sharing their designs for similar templates.
[@https://www.boost.org/people/daryle_walker.html Daryle Walker] designed the value-based sized templates.
[endsect]
[endsect]
[include gcd/math-gcd.qbk]
[include modular_arithmetic/extended_euclidean.qbk]
[include modular_arithmetic/mod_inverse.qbk]
[section:mask Integer Masks]
[section Overview]
The class templates in [@../../../../boost/integer/integer_mask.hpp <boost/integer/integer_mask.hpp>]
provide bit masks for a certain bit position or a contiguous-bit pack of a certain size.
The types of the masking constants come from the [link boost_integer.integer integer type selection templates] header.
[endsect]
[section Synopsis]
#include <cstddef> // for std::size_t
namespace boost
{
template <std::size_t Bit>
struct high_bit_mask_t
{
typedef ``['implementation-defined-type]`` least;
typedef ``['implementation-defined-type]`` fast;
static const least high_bit = ``['implementation-defined]``;
static const fast high_bit_fast = ``['implementation-defined]``;
static const std::size_t bit_position = Bit;
};
template <std::size_t Bits>
struct low_bits_mask_t
{
typedef ``['implementation-defined-type]`` least;
typedef ``['implementation-defined-type]`` fast;
static const least sig_bits = ``['implementation-defined]``;
static const fast sig_bits_fast = ``['implementation-defined]``;
static const std::size_t bit_count = Bits;
};
// Specializations for low_bits_mask_t exist for certain bit counts.
} // namespace boost
[endsect]
[section Single Bit-Mask Class Template]
The [^boost::high_bit_mask_t] class template provides constants for bit masks representing the bit at a
certain position. The masks are equivalent to the value 2[super Bit], where [^Bit] is the template parameter.
The bit position must be a nonnegative number from zero to ['Max], where Max is one less than the
number of bits supported by the largest unsigned built-in integral type. The following table describes
the members of an instantiation of [^high_bit_mask_t].
[table Members of the `boost::high_bit_mask_t` Class Template
[[Member][Meaning]]
[[[^least]][The smallest, unsigned, built-in type that supports the given bit position.]]
[[[^fast]][The easiest-to-manipulate analog of [^least].]]
[[[^high_bit]][A [^least] constant of the value 2[super Bit].]]
[[[^high_bit_fast]][A [^fast] analog of [^high_bit].]]
[[[^bit_position]][The value of the template parameter, in case its needed from a renamed instantiation of the class template.]]
]
[endsect]
[section Group Bit-Mask Class Template]
The [^boost::low_bits_mask_t] class template provides constants for bit masks
equivalent to the value (2[super Bits] - 1), where [^Bits] is the template parameter.
The parameter [^Bits] must be a non-negative integer from
zero to ['Max], where Max is the number of bits supported by the largest, unsigned, built-in integral type.
The following table describes the members of [^low_bits_mask_t].
[table Members of the [^boost::low_bits_mask_t] Class Template
[[Member][Meaning]]
[[[^least]][The smallest, unsigned built-in type that supports the given bit count.]]
[[[^fast]][The easiest-to-manipulate analog of [^least].]]
[[[^sig_bits]][A [^least] constant of the desired bit-masking value.]]
[[[^sig_bits_fast]][A [^fast] analog of [^sig_bits].]]
[[[^bit_count]][The value of the template parameter, in case its needed from a renamed instantiation of the class template.]]
]
[endsect]
[section Implementation Notes]
When [^Bits] is the exact size of a built-in unsigned type, the implementation has to change to
prevent undefined behavior. Therefore, there are specializations of [^low_bits_mask_t] at those bit counts.
[endsect]
[section Example]
#include <boost/integer/integer_mask.hpp>
//...
int main()
{
typedef boost::high_bit_mask_t<29> mask1_type;
typedef boost::low_bits_mask_t<15> mask2_type;
mask1_type::least my_var1;
mask2_type::fast my_var2;
//...
my_var1 |= mask1_type::high_bit;
my_var2 &= mask2_type::sig_bits_fast;
//...
}
[endsect]
[section Demonstration Program]
The program [@../../test/integer_mask_test.cpp integer_mask_test.cpp] is a simplistic demonstration of the
results from instantiating various examples of the bit mask class templates.
[endsect]
[section Rationale]
The class templates in this header are an extension of the [link boost_integer.integer integer type selection class templates].
The new class templates provide the same sized types, but also convenient masks to use when extracting the
highest or all the significant bits when the containing built-in type contains more bits.
This prevents contamination of values by the higher, unused bits.
[endsect]
[section Credits]
The author of the Boost bit mask class templates is [@https://www.boost.org/people/daryle_walker.html Daryle Walker].
[endsect]
[endsect]
[section:log2 Compile Time log2 Calculation]
The class template in [@../../../../boost/integer/static_log2.hpp <boost/integer/static_log2.hpp>]
determines the position of the highest bit in a given value. This facility is useful for solving generic programming problems.
[section Synopsis]
namespace boost
{
typedef ``['implementation-defined]`` static_log2_argument_type;
typedef ``['implementation-defined]`` static_log2_result_type;
template <static_log2_argument_type arg>
struct static_log2
{
static const static_log2_result_type value = ``['implementation-defined]``;
};
template < >
struct static_log2< 0 >
{
// The logarithm of zero is undefined.
};
} // namespace boost
[endsect]
[section Usage]
The [^boost::static_log2] class template takes one template parameter, a value of type
[^static_log2_argument_type]. The template only defines one member, [^value], which gives the
truncated, base-two logarithm of the template argument.
Since the logarithm of zero, for any base, is undefined, there is a specialization of [^static_log2]
for a template argument of zero. This specialization has no members, so an attempt to use the base-two
logarithm of zero results in a compile-time error.
Note:
* [^static_log2_argument_type] is an ['unsigned integer type] (C++ standard, 3.9.1p3).
* [^static_log2_result_type] is an ['integer type] (C++ standard, 3.9.1p7).
[endsect]
[section Demonstration Program]
The program [@../../test/static_log2_test.cpp static_log2_test.cpp] is a simplistic
demonstration of the results from instantiating various examples of the binary logarithm class template.
[endsect]
[section Rationale]
The base-two (binary) logarithm, abbreviated lb, function is occasionally used to give order-estimates
of computer algorithms. The truncated logarithm can be considered the highest power-of-two in a value,
which corresponds to the value's highest set bit (for binary integers). Sometimes the highest-bit position
could be used in generic programming, which requires the position to be available statically (['i.e.] at compile-time).
[endsect]
[section Credits]
The original version of the Boost binary logarithm class template was
written by [@https://www.boost.org/people/daryle_walker.html Daryle Walker] and then
enhanced by Giovanni Bajo with support for compilers without partial template specialization.
The current version was suggested, together with a reference implementation, by Vesa Karvonen.
Gennaro Prota wrote the actual source file.
[endsect]
[endsect]
[section:minmax Compile time min/max calculation]
The class templates in [@../../../../boost/integer/static_min_max.hpp <boost/integer/static_min_max.hpp>]
provide a compile-time evaluation of the minimum or maximum of two integers. These facilities are useful
for generic programming problems.
[section Synopsis]
namespace boost
{
typedef ``['implementation-defined]`` static_min_max_signed_type;
typedef ``['implementation-defined]`` static_min_max_unsigned_type;
template <static_min_max_signed_type Value1, static_min_max_signed_type Value2 >
struct static_signed_min;
template <static_min_max_signed_type Value1, static_min_max_signed_type Value2>
struct static_signed_max;
template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
struct static_unsigned_min;
template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
struct static_unsigned_max;
}
[endsect]
[section Usage]
The four class templates provide the combinations for finding the minimum or maximum of two [^signed] or
[^unsigned] ([^long]) parameters, /Value1/ and /Value2/, at compile-time. Each template has a single static data member,
[^value], which is set to the respective minimum or maximum of the template's parameters.
[endsect]
[section Example]
#include <boost/integer/static_min_max.hpp>
template < unsigned long AddendSize1, unsigned long AddendSize2 >
class adder
{
public:
static unsigned long const addend1_size = AddendSize1;
static unsigned long const addend2_size = AddendSize2;
static unsigned long const sum_size = boost::static_unsigned_max<AddendSize1, AddendSize2>::value + 1;
typedef int addend1_type[ addend1_size ];
typedef int addend2_type[ addend2_size ];
typedef int sum_type[ sum_size ];
void operator ()( addend1_type const &a1, addend2_type const &a2, sum_type &s ) const;
};
//...
int main()
{
int const a1[] = { 0, 4, 3 }; // 340
int const a2[] = { 9, 8 }; // 89
int s[ 4 ];
adder<3,2> obj;
obj( a1, a2, s ); // 's' should be 429 or { 9, 2, 4, 0 }
//...
}
[endsect]
[section Demonstration Program]
The program [@../../test/static_min_max_test.cpp static_min_max_test.cpp] is a simplistic demonstration of
various comparisons using the compile-time extrema class templates.
[endsect]
[section Rationale]
Sometimes the minimum or maximum of several values needs to be found for later compile-time processing,
['e.g.] for a bound for another class template.
[endsect]
[section Credits]
The author of the Boost compile-time extrema class templates is [@https://www.boost.org/people/daryle_walker.html Daryle Walker].
[endsect]
[endsect]
[section:history History]
[h4 1.56.0]
* Moved `<boost/cstdint.hpp>` into [@boost:/libs/config/index.html
Boost.Config].
[h4 1.42.0]
* Reverted Trunk to release branch state (i.e. a "known good state").
* Fixed issues: [@https://svn.boost.org/trac/boost/ticket/653 653],
[@https://svn.boost.org/trac/boost/ticket/3084 3084],
[@https://svn.boost.org/trac/boost/ticket/3177 3177],
[@https://svn.boost.org/trac/boost/ticket/3180 3180],
[@https://svn.boost.org/trac/boost/ticket/3548 3568],
[@https://svn.boost.org/trac/boost/ticket/3657 3657],
[@https://svn.boost.org/trac/boost/ticket/2134 2134].
* Added long long support to [^boost::static_log2], [^boost::static_signed_min], [^boost::static_signed_max],
[^boost::static_unsigned_min][^boost::static_unsigned_max], when available.
* The argument type and the result type of [^boost::static_signed_min] etc are now typedef'd.
Formerly, they were hardcoded as [^unsigned long] and [^int] respectively. Please, use the
provided typedefs in new code (and update old code as soon as possible).
[h4 1.32.0]
* The argument type and the result type of [^boost::static_log2] are now typedef'd.
Formerly, they were hardcoded as [^unsigned long] and [^int] respectively. Please, use the
provided typedefs in new code (and update old code as soon as possible).
[endsect]
[section:cstdint Removed from library: Standard Integer Types]
The [@boost:/libs/config/doc/html/boost_config/cstdint.html Boost.Config] module provides
the typedefs useful for writing portable code that requires certain
integer widths.
[endsect]

View File

@ -1,211 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Integer Bit Mask Templates</title>
</head>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<h1><img src="../../../c++boost.gif" alt="c++boost.gif (8819 bytes)"
align="middle" width="277" height="86">Integer Bit Mask Templates</h1>
<p>The class templates in <cite><a href="../../../boost/integer/integer_mask.hpp">&lt;boost/integer/integer_mask.hpp&gt;</a></cite> provide bit masks for a certain bit position or a contiguous-bit pack of a certain size. The types of the masking constants come from the <a href="../integer.htm">integer type selection templates</a> header.</p>
<h2><a name="contents">Contents</a></h2>
<ul>
<li><a href="#contents">Contents</a></li>
<li><a href="#synopsis">Synopsis</a></li>
<li><a href="#single">Single Bit-Mask Class Template</a></li>
<li><a href="#group">Group Bit-Mask Class Template</a></li>
<li><a href="#example">Example</a></li>
<li><a href="#demo">Demonstration Program</a></li>
<li><a href="#rationale">Rationale</a></li>
<li><a href="#credits">Credits</a></li>
</ul>
<h2><a name="synopsis">Synopsis</a></h2>
<blockquote><pre>
#include &lt;cstddef&gt; <i>// for std::size_t</i>
namespace boost
{
template &lt; std::size_t Bit &gt;
struct high_bit_mask_t
{
typedef <em>implementation_supplied</em> least;
typedef <em>implementation_supplied</em> fast;
static const least high_bit = <em>implementation_defined</em>;
static const fast high_bit_fast = <em>implementation_defined</em>;
static const std::size_t bit_position = Bit;
};
template &lt; std::size_t Bits &gt;
struct low_bits_mask_t
{
typedef <em>implementation_supplied</em> least;
typedef <em>implementation_supplied</em> fast;
static const least sig_bits = <em>implementation_defined</em>;
static const fast sig_bits_fast = <em>implementation_defined</em>;
static const std::size_t bit_count = Bits;
};
// Specializations for low_bits_mask_t exist for certain bit counts.
} // namespace boost
</pre></blockquote>
<h2><a name="single">Single Bit-Mask Class Template</a></h2>
<p>The <code>boost::high_bit_mask_t</code> class template provides
constants for bit masks representing the bit at a certain position. The
masks are equivalent to the value 2<sup><code>Bit</code></sup>, where
<code>Bit</code> is the template parameter. The bit position must be a
nonnegative number from zero to <i>Max</i>, where <dfn>Max</dfn> is one
less than the number of bits supported by the largest unsigned built-in
integral type. The following table describes the members of an
instantiation of <code>high_bit_mask_t</code>.</p>
<table border="1" cellpadding="5">
<caption>Members of the <code>boost::high_bit_mask_t</code> Class
Template</caption>
<tr>
<th>Member</th>
<th>Meaning</th>
</tr>
<tr>
<td><code>least</code></td>
<td>The smallest unsigned built-in type that supports the given
bit position.</td>
</tr>
<tr>
<td><code>fast</code></td>
<td>The quick-to-manipulate analog of <code>least</code>.</td>
</tr>
<tr>
<td><code>high_bit</code></td>
<td>A <code>least</code> constant of the desired bit-masking
value.</td>
</tr>
<tr>
<td><code>high_bit_fast</code></td>
<td>A <code>fast</code> analog of <code>high_bit</code>.</td>
</tr>
<tr>
<td><code>bit_position</code></td>
<td>The value of the template parameter, in case its needed from
a renamed instantiation of the class template.</td>
</tr>
</table>
<h2><a name="group">Group Bit-Mask Class Template</a></h2>
<p>The <code>boost::low_bits_mask_t</code> class template provides
constants for bit masks representing the lowest bits of a certain
amount. The masks are equivalent to the value
(2<sup><code>Bits</code></sup> - 1), where <code>Bits</code> is the
template parameter. The bit amount must be a nonnegative number from
zero to <i>Max</i>, where <dfn>Max</dfn> is the number of bits supported
by the largest unsigned built-in integral type. The following table
describes the members of an instantiation of
<code>low_bits_mask_t</code>.</p>
<table border="1" cellpadding="5">
<caption>Members of the <code>boost::low_bits_mask_t</code> Class
Template</caption>
<tr>
<th>Member</th>
<th>Meaning</th>
</tr>
<tr>
<td><code>least</code></td>
<td>The smallest unsigned built-in type that supports the given
bit count.</td>
</tr>
<tr>
<td><code>fast</code></td>
<td>The quick-to-manipulate analog of <code>least</code>.</td>
</tr>
<tr>
<td><code>sig_bits</code></td>
<td>A <code>least</code> constant of the desired bit-masking
value.</td>
</tr>
<tr>
<td><code>sig_bits_fast</code></td>
<td>A <code>fast</code> analog of <code>sig_bits</code>.</td>
</tr>
<tr>
<td><code>bit_count</code></td>
<td>The value of the template parameter, in case its needed from
a renamed instantiation of the class template.</td>
</tr>
</table>
<p><strong>Implementation Note</strong><br>
When <code>Bits</code> is the exact size of a built-in unsigned type,
the implementation has to change to prevent undefined behavior.
Therefore, there are specializations of <code>low_bits_mask_t</code> at
those bit counts.</p>
<h2><a name="example">Example</a></h2>
<blockquote><pre>
#include &lt;boost/integer/integer_mask.hpp&gt;
//...
int main()
{
typedef boost::high_bit_mask_t&lt;29&gt; mask1_type;
typedef boost::low_bits_mask_t&lt;15&gt; mask2_type;
mask1_type::least my_var1;
mask2_type::fast my_var2;
//...
my_var1 |= mask1_type::high_bit;
my_var2 &amp;= mask2_type::sig_bits_fast;
//...
}
</pre></blockquote>
<h2><a name="demo">Demonstration Program</a></h2>
<p>The program <a href="../test/integer_mask_test.cpp">integer_mask_test.cpp</a>
is a simplistic demonstration of the results from instantiating various
examples of the bit mask class templates.</p>
<h2><a name="rationale">Rationale</a></h2>
<p>The class templates in this header are an extension of the <a
href="../integer.htm">integer type selection class templates</a>. The new
class templates provide the same sized types, but also convienent masks
to use when extracting the highest or all the significant bits when the
containing built-in type contains more bits. This prevents
contaimination of values by the higher, unused bits.</p>
<h2><a name="credits">Credits</a></h2>
<p>The author of the Boost bit mask class templates is <a
href="../../../people/daryle_walker.html">Daryle Walker</a>.</p>
<hr>
<p>Revised September 23, 2001</p>
<p>&copy; Copyright Daryle Walker 2001. Permission to copy, use,
modify, sell and distribute this document is granted provided this
copyright notice appears in all copies. This document is provided
&quot;as is&quot; without express or implied warranty, and with no claim
as to its suitability for any purpose.</p>
</body>
</html>

View File

@ -0,0 +1,53 @@
[section:extended_euclidean Extended Euclidean Algorithm]
[section Introduction]
The extended Euclidean algorithm solves the integer relation /mx + ny/ = gcd(/m/, /n/) for /x/ and /y/.
[endsect]
[section Synopsis]
#include <boost/integer/extended_euclidean.hpp>
namespace boost { namespace integer {
template<class Z>
struct euclidean_result_t {
Z gcd;
Z x;
Z y;
};
template<class Z>
euclidean_result_t<Z> extended_euclidean(Z m, Z n);
}}
[endsect]
[section Usage]
int m = 12;
int n = 15;
auto res = extended_euclidean(m, n);
int gcd = res.gcd;
int x = res.x;
int y = res.y;
// mx + ny = gcd(m,n) should now hold
[endsect]
[section References]
Wagstaff, Samuel S., ['The Joy of Factoring], Vol. 68. American Mathematical Soc., 2013.
[endsect]
[endsect]
[/
Copyright 2018 Nick Thompson.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
https://www.boost.org/LICENSE_1_0.txt).
]

View File

@ -0,0 +1,50 @@
[section:mod_inverse Modular Multiplicative Inverse]
[section Introduction]
The modular multiplicative inverse of a number /a/ is that number /x/ which satisfies /ax/ = 1 mod /p/.
A fast algorithm for computing modular multiplicative inverses based on the extended Euclidean algorithm exists and is provided by Boost.
[endsect]
[section Synopsis]
#include <boost/integer/mod_inverse.hpp>
namespace boost { namespace integer {
template<class Z>
Z mod_inverse(Z a, Z m);
}}
[endsect]
[section Usage]
int x = mod_inverse(2, 5);
// prints x = 3:
std::cout << "x = " << x << "\n";
int y = mod_inverse(2, 4);
if (y == 0)
{
std::cout << "There is no inverse of 2 mod 4\n";
}
Multiplicative modular inverses exist if and only if /a/ and /m/ are coprime.
If /a/ and /m/ share a common factor, then `mod_inverse(a, m)` returns zero.
[endsect]
[section References]
Wagstaff, Samuel S., ['The Joy of Factoring], Vol. 68. American Mathematical Soc., 2013.
[endsect]
[endsect]
[/
Copyright 2018 Nick Thompson.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
https://www.boost.org/LICENSE_1_0.txt).
]

View File

@ -1,123 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Binary Logarithm Template</title>
</head>
<body bgcolor="white" text="black">
<h1><img src="../../../c++boost.gif" alt="c++boost.gif (8819 bytes)"
align="middle" width="277" height="86">Binary Logarithm Template</h1>
<p>The class template in <cite><a href="../../../boost/integer/static_log2.hpp">&lt;boost/integer/static_log2.hpp&gt;</a></cite> determines the position of the highest bit in a given value. This facility is useful for solving generic programming problems.</p>
<h2><a name="contents">Contents</a></h2>
<ul>
<li><a href="#contents">Contents</a></li>
<li><a href="#synopsis">Synopsis</a></li>
<li><a href="#usage">Usage</a></li>
<li><a href="#example">Example</a></li>
<li><a href="#demo">Demonstration Program</a></li>
<li><a href="#rationale">Rationale</a></li>
<li><a href="#credits">Credits</a></li>
</ul>
<h2><a name="synopsis">Synopsis</a></h2>
<blockquote><pre>
namespace boost
{
template &lt; unsigned long Value &gt;
struct static_log2
{
static const int value = <em>implementation_defined</em>;
};
template &lt; &gt;
struct static_log2&lt; 0ul &gt;
{
// The logarithm of zero is undefined.
};
} // namespace boost
</pre></blockquote>
<h2><a name="usage">Usage</a></h2>
<p>The <code>boost::static_log2</code> class template takes one template
parameter, a value of type <code>unsigned long</code>. The template
only defines one member, <code>value</code>, that returns the truncated
base-two logarithm of the template parameter.</p>
<p>Since the logarithm of zero, for any base, is undefined, there is a
specialization of <code>static_log2</code> for a template parameter
of zero. This specialization has no members, so an attempt to use
the base-two logarithm of zero results in a compile-time error.</p>
<h2><a name="example">Example</a></h2>
<blockquote><pre>
#include &lt;boost/integer/static_log2.hpp&gt;
template &lt; unsigned long Value &gt;
bool is_it_what()
{
typedef boost::static_log2&lt;Value&gt; lb_type;
int temp = lb_type::value;
//...
return (temp % 2) != 0;
}
//...
int main()
{
bool temp = is_it_what&lt;2000&gt;();
//...
#if 0
temp = is_it_what&lt;0&gt;(); // would give an error
#endif
//...
temp = is_it_what&lt;24&gt;();
//...
}
</pre></blockquote>
<h2><a name="demo">Demonstration Program</a></h2>
<p>The program <a href="../test/static_log2_test.cpp">static_log2_test.cpp</a>
is a simplistic demonstration of the results from instantiating various
examples of the binary logarithm class template.</p>
<h2><a name="rationale">Rationale</a></h2>
<p>The base-two (binary) logarithm, abbreviated <dfn>lb</dfn>, function
is occasionally used to give order-estimates of computer algorithms.
The truncated logarithm can be considered the highest power-of-two in a
value, which corresponds to the value's highest set bit (for binary
integers). Sometimes the highest-bit position could be used in generic
programming, which requires the position to be statically (<i>i.e.</i>
at compile-time) available.</p>
<h2><a name="credits">Credits</a></h2>
<p>The author of the Boost binary logarithm class template is <a
href="../../../people/daryle_walker.html">Daryle Walker</a>. Giovanni Bajo
added support for compilers without partial template specialization.</p>
<hr>
<p>Revised May 14, 2002</p>
<p>&copy; Copyright Daryle Walker 2001. Permission to copy, use,
modify, sell and distribute this document is granted provided this
copyright notice appears in all copies. This document is provided
&quot;as is&quot; without express or implied warranty, and with no claim
as to its suitability for any purpose.</p>
</body>
</html>

View File

@ -1,121 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Compile-Time Extrema Templates</title>
</head>
<body bgcolor="white" text="black" link="blue" alink="red" vlink="purple">
<h1><img src="../../../c++boost.gif" alt="c++boost.gif (8819 bytes)"
align="middle" width="277" height="86">Compile-Time Extrema
Templates</h1>
<p>The class templates in <cite><a
href="../../../boost/integer/static_min_max.hpp">&lt;boost/integer/static_min_max.hpp&gt;</a></cite>
provide a compile-time evaluation of the minimum or maximum of
two integers. These facilities are useful for generic programming problems.</p>
<h2><a name="contents">Contents</a></h2>
<ul>
<li><a href="#contents">Contents</a></li>
<li><a href="#synopsis">Synopsis</a></li>
<li><a href="#usage">Usage</a></li>
<li><a href="#example">Example</a></li>
<li><a href="#demo">Demonstration Program</a></li>
<li><a href="#rationale">Rationale</a></li>
<li><a href="#credits">Credits</a></li>
</ul>
<h2><a name="synopsis">Synopsis</a></h2>
<blockquote><pre>
namespace boost
{
template &lt; long Value1, long Value2 &gt;
struct static_signed_min;
template &lt; long Value1, long Value2 &gt;
struct static_signed_max;
template &lt; unsigned long Value1, unsigned long Value2 &gt;
struct static_unsigned_min;
template &lt; unsigned long Value1, unsigned long Value2 &gt;
struct static_unsigned_max;
}
</pre></blockquote>
<h2><a name="usage">Usage</a></h2>
<p>The four class templates provide the combinations for finding the
minimum or maximum of two signed or <code>unsigned</code>
(<code>long</code>) parameters, <var>Value1</var> and <var>Value2</var>,
at compile-time. Each template has a single static data member,
<code>value</code>, which is set to the respective minimum or maximum
of the template's parameters.</p>
<h2><a name="example">Example</a></h2>
<blockquote><pre>
#include &lt;boost/integer/static_min_max.hpp&gt;
template &lt; unsigned long AddendSize1, unsigned long AddendSize2 &gt;
class adder
{
public:
static unsigned long const addend1_size = AddendSize1;
static unsigned long const addend2_size = AddendSize2;
static unsigned long const sum_size = boost::static_unsigned_max&lt;AddendSize1, AddendSize2&gt;::value + 1;
typedef int addend1_type[ addend1_size ];
typedef int addend2_type[ addend2_size ];
typedef int sum_type[ sum_size ];
void operator ()( addend1_type const &amp;a1, addend2_type const &amp;a2, sum_type &amp;s ) const;
};
//...
int main()
{
int const a1[] = { 0, 4, 3 }; // 340
int const a2[] = { 9, 8 }; // 89
int s[ 4 ];
adder&lt;3,2&gt; obj;
obj( a1, a2, s ); // 's' should be 429 or { 9, 2, 4, 0 }
//...
}
</pre></blockquote>
<h2><a name="demo">Demonstration Program</a></h2>
<p>The program <a
href="../test/static_min_max_test.cpp">static_min_max_test.cpp</a> is a
simplistic demonstration of various comparisons using the compile-time
extrema class templates.</p>
<h2><a name="rationale">Rationale</a></h2>
<p>Sometimes the minimum or maximum of several values needs to be found
for later compile-time processing, <i>e.g.</i> for a bound for another
class template.</p>
<h2><a name="credits">Credits</a></h2>
<p>The author of the Boost compile-time extrema class templates is <a
href="../../../people/daryle_walker.html">Daryle Walker</a>.</p>
<hr>
<p>Revised October 12, 2001</p>
<p>&copy; Copyright Daryle Walker 2001. Permission to copy, use,
modify, sell and distribute this document is granted provided this
copyright notice appears in all copies. This document is provided
&quot;as is&quot; without express or implied warranty, and with no claim
as to its suitability for any purpose.</p>
</body>
</html>

View File

@ -1,376 +0,0 @@
// boost cstdint.hpp header file ------------------------------------------//
// (C) Copyright boost.org 1999. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 31 Oct 01 use BOOST_HAS_LONG_LONG to check for "long long" (Jens M.)
// 16 Apr 01 check LONGLONG_MAX when looking for "long long" (Jens Maurer)
// 23 Jan 01 prefer "long" over "int" for int32_t and intmax_t (Jens Maurer)
// 12 Nov 00 Merged <boost/stdint.h> (Jens Maurer)
// 23 Sep 00 Added INTXX_C macro support (John Maddock).
// 22 Sep 00 Better 64-bit support (John Maddock)
// 29 Jun 00 Reimplement to avoid including stdint.h within namespace boost
// 8 Aug 99 Initial version (Beman Dawes)
#ifndef BOOST_CSTDINT_HPP
#define BOOST_CSTDINT_HPP
#include <boost/config.hpp>
#ifdef BOOST_HAS_STDINT_H
// The following #include is an implementation artifact; not part of interface.
# ifdef __hpux
// HP-UX has a vaguely nice <stdint.h> in a non-standard location
# include <inttypes.h>
# ifdef __STDC_32_MODE__
// this is triggered with GCC, because it defines __cplusplus < 199707L
# define BOOST_NO_INT64_T
# endif
# elif defined(__FreeBSD__)
# include <inttypes.h>
# else
# include <stdint.h>
# endif
namespace boost
{
using ::int8_t;
using ::int_least8_t;
using ::int_fast8_t;
using ::uint8_t;
using ::uint_least8_t;
using ::uint_fast8_t;
using ::int16_t;
using ::int_least16_t;
using ::int_fast16_t;
using ::uint16_t;
using ::uint_least16_t;
using ::uint_fast16_t;
using ::int32_t;
using ::int_least32_t;
using ::int_fast32_t;
using ::uint32_t;
using ::uint_least32_t;
using ::uint_fast32_t;
# ifndef BOOST_NO_INT64_T
using ::int64_t;
using ::int_least64_t;
using ::int_fast64_t;
using ::uint64_t;
using ::uint_least64_t;
using ::uint_fast64_t;
# endif
using ::intmax_t;
using ::uintmax_t;
} // namespace boost
#elif defined(__FreeBSD__) && (__FreeBSD__ <= 4)
// FreeBSD has an <inttypes.h> that contains much of what we need
# include <inttypes.h>
namespace boost {
using ::int8_t;
typedef int8_t int_least8_t;
typedef int8_t int_fast8_t;
using ::uint8_t;
typedef uint8_t uint_least8_t;
typedef uint8_t uint_fast8_t;
using ::int16_t;
typedef int16_t int_least16_t;
typedef int16_t int_fast16_t;
using ::uint16_t;
typedef uint16_t uint_least16_t;
typedef uint16_t uint_fast16_t;
using ::int32_t;
typedef int32_t int_least32_t;
typedef int32_t int_fast32_t;
using ::uint32_t;
typedef uint32_t uint_least32_t;
typedef uint32_t uint_fast32_t;
# ifndef BOOST_NO_INT64_T
using ::int64_t;
typedef int64_t int_least64_t;
typedef int64_t int_fast64_t;
using ::uint64_t;
typedef uint64_t uint_least64_t;
typedef uint64_t uint_fast64_t;
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
# else
typedef int32_t intmax_t;
typedef uint32_t uintmax_t;
# endif
} // namespace boost
#else // BOOST_HAS_STDINT_H
# include <limits.h> // implementation artifact; not part of interface
namespace boost
{
// These are fairly safe guesses for some 16-bit, and most 32-bit and 64-bit
// platforms. For other systems, they will have to be hand tailored.
//
// Because the fast types are assumed to be the same as the undecorated types,
// it may be possible to hand tailor a more efficient implementation. Such
// an optimization may be illusionary; on the Intel x86-family 386 on, for
// example, byte arithmetic and load/stores are as fast as "int" sized ones.
// 8-bit types ------------------------------------------------------------//
# if UCHAR_MAX == 0xff
typedef signed char int8_t;
typedef signed char int_least8_t;
typedef signed char int_fast8_t;
typedef unsigned char uint8_t;
typedef unsigned char uint_least8_t;
typedef unsigned char uint_fast8_t;
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
// 16-bit types -----------------------------------------------------------//
# if USHRT_MAX == 0xffff
typedef short int16_t;
typedef short int_least16_t;
typedef short int_fast16_t;
typedef unsigned short uint16_t;
typedef unsigned short uint_least16_t;
typedef unsigned short uint_fast16_t;
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
// 32-bit types -----------------------------------------------------------//
# if ULONG_MAX == 0xffffffff
typedef long int32_t;
typedef long int_least32_t;
typedef long int_fast32_t;
typedef unsigned long uint32_t;
typedef unsigned long uint_least32_t;
typedef unsigned long uint_fast32_t;
# elif UINT_MAX == 0xffffffff
typedef int int32_t;
typedef int int_least32_t;
typedef int int_fast32_t;
typedef unsigned int uint32_t;
typedef unsigned int uint_least32_t;
typedef unsigned int uint_fast32_t;
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
# if defined(BOOST_HAS_LONG_LONG) && \
!defined(BOOST_MSVC) && !defined(__BORLANDC__) && \
(!defined(__GLIBCPP__) || defined(_GLIBCPP_USE_LONG_LONG)) && \
(defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX))
# if defined(__hpux)
// HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions
# elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615ULL) || (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615ULL) || (defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615ULL)
// 2**64 - 1
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
typedef long long intmax_t;
typedef unsigned long long uintmax_t;
typedef long long int64_t;
typedef long long int_least64_t;
typedef long long int_fast64_t;
typedef unsigned long long uint64_t;
typedef unsigned long long uint_least64_t;
typedef unsigned long long uint_fast64_t;
# elif ULONG_MAX != 0xffffffff
# if ULONG_MAX == 18446744073709551615 // 2**64 - 1
typedef long intmax_t;
typedef unsigned long uintmax_t;
typedef long int64_t;
typedef long int_least64_t;
typedef long int_fast64_t;
typedef unsigned long uint64_t;
typedef unsigned long uint_least64_t;
typedef unsigned long uint_fast64_t;
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
# elif defined(BOOST_HAS_MS_INT64)
//
// we have Borland/Intel/Microsoft __int64:
//
typedef __int64 intmax_t;
typedef unsigned __int64 uintmax_t;
typedef __int64 int64_t;
typedef __int64 int_least64_t;
typedef __int64 int_fast64_t;
typedef unsigned __int64 uint64_t;
typedef unsigned __int64 uint_least64_t;
typedef unsigned __int64 uint_fast64_t;
# else // assume no 64-bit integers
# define BOOST_NO_INT64_T
typedef int32_t intmax_t;
typedef uint32_t uintmax_t;
# endif
} // namespace boost
#endif // BOOST_HAS_STDINT_H
#endif // BOOST_CSTDINT_HPP
/****************************************************
Macro definition section:
Define various INTXX_C macros only if
__STDC_CONSTANT_MACROS is defined.
Undefine the macros if __STDC_CONSTANT_MACROS is
not defined and the macros are (cf <cassert>).
Added 23rd September 2000 (John Maddock).
Modified 11th September 2001 to be excluded when
BOOST_HAS_STDINT_H is defined (John Maddock).
******************************************************/
#if defined(__STDC_CONSTANT_MACROS) && !defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(BOOST_HAS_STDINT_H)
# define BOOST__STDC_CONSTANT_MACROS_DEFINED
# if defined(BOOST_HAS_MS_INT64)
//
// Borland/Intel/Microsoft compilers have width specific suffixes:
//
# define INT8_C(value) value##i8
# define INT16_C(value) value##i16
# define INT32_C(value) value##i32
# define INT64_C(value) value##i64
# ifdef __BORLANDC__
// Borland bug: appending ui8 makes the type a signed char
# define UINT8_C(value) static_cast<unsigned char>(value##u)
# else
# define UINT8_C(value) value##ui8
# endif
# define UINT16_C(value) value##ui16
# define UINT32_C(value) value##ui32
# define UINT64_C(value) value##ui64
# define INTMAX_C(value) value##i64
# define UINTMAX_C(value) value##ui64
# else
// do it the old fashioned way:
// 8-bit types ------------------------------------------------------------//
# if UCHAR_MAX == 0xff
# define INT8_C(value) static_cast<boost::int8_t>(value)
# define UINT8_C(value) static_cast<boost::uint8_t>(value##u)
# endif
// 16-bit types -----------------------------------------------------------//
# if USHRT_MAX == 0xffff
# define INT16_C(value) static_cast<boost::int16_t>(value)
# define UINT16_C(value) static_cast<boost::uint16_t>(value##u)
# endif
// 32-bit types -----------------------------------------------------------//
# if UINT_MAX == 0xffffffff
# define INT32_C(value) value
# define UINT32_C(value) value##u
# elif ULONG_MAX == 0xffffffff
# define INT32_C(value) value##L
# define UINT32_C(value) value##uL
# endif
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
# if defined(BOOST_HAS_LONG_LONG) && \
(defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX))
# if defined(__hpux)
// HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions
# elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615U) || \
(defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615U) || \
(defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615U)
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
# define INT64_C(value) value##LL
# define UINT64_C(value) value##uLL
# elif ULONG_MAX != 0xffffffff
# if ULONG_MAX == 18446744073709551615 // 2**64 - 1
# define INT64_C(value) value##L
# define UINT64_C(value) value##uL
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
# endif
# ifdef BOOST_NO_INT64_T
# define INTMAX_C(value) INT32_C(value)
# define UINTMAX_C(value) UINT32_C(value)
# else
# define INTMAX_C(value) INT64_C(value)
# define UINTMAX_C(value) UINT64_C(value)
# endif
# endif // Borland/Microsoft specific width suffixes
#elif defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(__STDC_CONSTANT_MACROS) && !defined(BOOST_HAS_STDINT_H)
//
// undef all the macros:
//
# undef INT8_C
# undef INT16_C
# undef INT32_C
# undef INT64_C
# undef UINT8_C
# undef UINT16_C
# undef UINT32_C
# undef UINT64_C
# undef INTMAX_C
# undef UINTMAX_C
#endif // __STDC_CONSTANT_MACROS_DEFINED etc.

View File

@ -1,12 +1,10 @@
// boost integer.hpp header file -------------------------------------------//
// (C) Copyright Beman Dawes 1999. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// Copyright Beman Dawes and Daryle Walker 1999. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for most recent version including documentation.
// See https://www.boost.org/libs/integer for documentation.
// Revision History
// 22 Sep 01 Added value-based integer templates. (Daryle Walker)
@ -19,8 +17,22 @@
#include <boost/integer_fwd.hpp> // self include
#include <boost/integer_traits.hpp> // for boost::integer_traits
#include <boost/limits.hpp> // for std::numeric_limits
#include <boost/integer_traits.hpp> // for boost::::boost::integer_traits
#include <boost/limits.hpp> // for ::std::numeric_limits
#include <boost/cstdint.hpp> // for boost::int64_t and BOOST_NO_INTEGRAL_INT64_T
#include <boost/static_assert.hpp>
//
// We simply cannot include this header on gcc without getting copious warnings of the kind:
//
// boost/integer.hpp:77:30: warning: use of C99 long long integer constant
//
// And yet there is no other reasonable implementation, so we declare this a system header
// to suppress these warnings.
//
#if defined(__GNUC__) && (__GNUC__ >= 4)
#pragma GCC system_header
#endif
namespace boost
{
@ -30,97 +42,218 @@ namespace boost
// fast integers from least integers
// int_fast_t<> works correctly for unsigned too, in spite of the name.
template< typename LeastInt >
struct int_fast_t { typedef LeastInt fast; }; // imps may specialize
struct int_fast_t
{
typedef LeastInt fast;
typedef fast type;
}; // imps may specialize
// convert category to type
namespace detail{
// convert category to type
template< int Category > struct int_least_helper {}; // default is empty
template< int Category > struct uint_least_helper {}; // default is empty
// specializatons: 1=long, 2=int, 3=short, 4=signed char,
// 6=unsigned long, 7=unsigned int, 8=unsigned short, 9=unsigned long
// 6=unsigned long, 7=unsigned int, 8=unsigned short, 9=unsigned char
// no specializations for 0 and 5: requests for a type > long are in error
template<> struct int_least_helper<1> { typedef long least; };
template<> struct int_least_helper<2> { typedef int least; };
template<> struct int_least_helper<3> { typedef short least; };
template<> struct int_least_helper<4> { typedef signed char least; };
template<> struct int_least_helper<6> { typedef unsigned long least; };
template<> struct int_least_helper<7> { typedef unsigned int least; };
template<> struct int_least_helper<8> { typedef unsigned short least; };
template<> struct int_least_helper<9> { typedef unsigned char least; };
#ifdef BOOST_HAS_LONG_LONG
template<> struct int_least_helper<1> { typedef boost::long_long_type least; };
#elif defined(BOOST_HAS_MS_INT64)
template<> struct int_least_helper<1> { typedef __int64 least; };
#endif
template<> struct int_least_helper<2> { typedef long least; };
template<> struct int_least_helper<3> { typedef int least; };
template<> struct int_least_helper<4> { typedef short least; };
template<> struct int_least_helper<5> { typedef signed char least; };
#ifdef BOOST_HAS_LONG_LONG
template<> struct uint_least_helper<1> { typedef boost::ulong_long_type least; };
#elif defined(BOOST_HAS_MS_INT64)
template<> struct uint_least_helper<1> { typedef unsigned __int64 least; };
#endif
template<> struct uint_least_helper<2> { typedef unsigned long least; };
template<> struct uint_least_helper<3> { typedef unsigned int least; };
template<> struct uint_least_helper<4> { typedef unsigned short least; };
template<> struct uint_least_helper<5> { typedef unsigned char least; };
template <int Bits>
struct exact_signed_base_helper{};
template <int Bits>
struct exact_unsigned_base_helper{};
template <> struct exact_signed_base_helper<sizeof(signed char)* CHAR_BIT> { typedef signed char exact; };
template <> struct exact_unsigned_base_helper<sizeof(unsigned char)* CHAR_BIT> { typedef unsigned char exact; };
#if USHRT_MAX != UCHAR_MAX
template <> struct exact_signed_base_helper<sizeof(short)* CHAR_BIT> { typedef short exact; };
template <> struct exact_unsigned_base_helper<sizeof(unsigned short)* CHAR_BIT> { typedef unsigned short exact; };
#endif
#if UINT_MAX != USHRT_MAX
template <> struct exact_signed_base_helper<sizeof(int)* CHAR_BIT> { typedef int exact; };
template <> struct exact_unsigned_base_helper<sizeof(unsigned int)* CHAR_BIT> { typedef unsigned int exact; };
#endif
#if ULONG_MAX != UINT_MAX && ( !defined __TI_COMPILER_VERSION__ || \
( __TI_COMPILER_VERSION__ >= 7000000 && !defined __TI_40BIT_LONG__ ) )
template <> struct exact_signed_base_helper<sizeof(long)* CHAR_BIT> { typedef long exact; };
template <> struct exact_unsigned_base_helper<sizeof(unsigned long)* CHAR_BIT> { typedef unsigned long exact; };
#endif
#if defined(BOOST_HAS_LONG_LONG) &&\
((defined(ULLONG_MAX) && (ULLONG_MAX != ULONG_MAX)) ||\
(defined(ULONG_LONG_MAX) && (ULONG_LONG_MAX != ULONG_MAX)) ||\
(defined(ULONGLONG_MAX) && (ULONGLONG_MAX != ULONG_MAX)) ||\
(defined(_ULLONG_MAX) && (_ULLONG_MAX != ULONG_MAX)))
template <> struct exact_signed_base_helper<sizeof(boost::long_long_type)* CHAR_BIT> { typedef boost::long_long_type exact; };
template <> struct exact_unsigned_base_helper<sizeof(boost::ulong_long_type)* CHAR_BIT> { typedef boost::ulong_long_type exact; };
#endif
} // namespace detail
// integer templates specifying number of bits ---------------------------//
// signed
template< int Bits > // bits (including sign) required
struct int_t
struct int_t : public boost::detail::exact_signed_base_helper<Bits>
{
typedef typename int_least_helper
BOOST_STATIC_ASSERT_MSG(Bits <= (int)(sizeof(boost::intmax_t) * CHAR_BIT),
"No suitable signed integer type with the requested number of bits is available.");
typedef typename boost::detail::int_least_helper
<
(Bits-1 <= std::numeric_limits<long>::digits) +
(Bits-1 <= std::numeric_limits<int>::digits) +
(Bits-1 <= std::numeric_limits<short>::digits) +
(Bits-1 <= std::numeric_limits<signed char>::digits)
#ifdef BOOST_HAS_LONG_LONG
(Bits <= (int)(sizeof(boost::long_long_type) * CHAR_BIT)) +
#else
1 +
#endif
(Bits-1 <= ::std::numeric_limits<long>::digits) +
(Bits-1 <= ::std::numeric_limits<int>::digits) +
(Bits-1 <= ::std::numeric_limits<short>::digits) +
(Bits-1 <= ::std::numeric_limits<signed char>::digits)
>::least least;
typedef typename int_fast_t<least>::fast fast;
typedef typename int_fast_t<least>::type fast;
};
// unsigned
template< int Bits > // bits required
struct uint_t
struct uint_t : public boost::detail::exact_unsigned_base_helper<Bits>
{
typedef typename int_least_helper
<
5 +
(Bits <= std::numeric_limits<unsigned long>::digits) +
(Bits <= std::numeric_limits<unsigned int>::digits) +
(Bits <= std::numeric_limits<unsigned short>::digits) +
(Bits <= std::numeric_limits<unsigned char>::digits)
BOOST_STATIC_ASSERT_MSG(Bits <= (int)(sizeof(boost::uintmax_t) * CHAR_BIT),
"No suitable unsigned integer type with the requested number of bits is available.");
#if (defined(BOOST_BORLANDC) || defined(__CODEGEAR__)) && defined(BOOST_NO_INTEGRAL_INT64_T)
// It's really not clear why this workaround should be needed... shrug I guess! JM
BOOST_STATIC_CONSTANT(int, s =
6 +
(Bits <= ::std::numeric_limits<unsigned long>::digits) +
(Bits <= ::std::numeric_limits<unsigned int>::digits) +
(Bits <= ::std::numeric_limits<unsigned short>::digits) +
(Bits <= ::std::numeric_limits<unsigned char>::digits));
typedef typename detail::int_least_helper< ::boost::uint_t<Bits>::s>::least least;
#else
typedef typename boost::detail::uint_least_helper
<
#ifdef BOOST_HAS_LONG_LONG
(Bits <= (int)(sizeof(boost::long_long_type) * CHAR_BIT)) +
#else
1 +
#endif
(Bits <= ::std::numeric_limits<unsigned long>::digits) +
(Bits <= ::std::numeric_limits<unsigned int>::digits) +
(Bits <= ::std::numeric_limits<unsigned short>::digits) +
(Bits <= ::std::numeric_limits<unsigned char>::digits)
>::least least;
typedef typename int_fast_t<least>::fast fast;
#endif
typedef typename int_fast_t<least>::type fast;
// int_fast_t<> works correctly for unsigned too, in spite of the name.
};
// integer templates specifying extreme value ----------------------------//
// signed
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
template< boost::long_long_type MaxValue > // maximum value to require support
#else
template< long MaxValue > // maximum value to require support
struct int_max_value_t
#endif
struct int_max_value_t
{
typedef typename int_least_helper
typedef typename boost::detail::int_least_helper
<
(MaxValue <= integer_traits<long>::const_max) +
(MaxValue <= integer_traits<int>::const_max) +
(MaxValue <= integer_traits<short>::const_max) +
(MaxValue <= integer_traits<signed char>::const_max)
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
(MaxValue <= ::boost::integer_traits<boost::long_long_type>::const_max) +
#else
1 +
#endif
(MaxValue <= ::boost::integer_traits<long>::const_max) +
(MaxValue <= ::boost::integer_traits<int>::const_max) +
(MaxValue <= ::boost::integer_traits<short>::const_max) +
(MaxValue <= ::boost::integer_traits<signed char>::const_max)
>::least least;
typedef typename int_fast_t<least>::fast fast;
typedef typename int_fast_t<least>::type fast;
};
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
template< boost::long_long_type MinValue > // minimum value to require support
#else
template< long MinValue > // minimum value to require support
struct int_min_value_t
#endif
struct int_min_value_t
{
typedef typename int_least_helper
typedef typename boost::detail::int_least_helper
<
(MinValue >= integer_traits<long>::const_min) +
(MinValue >= integer_traits<int>::const_min) +
(MinValue >= integer_traits<short>::const_min) +
(MinValue >= integer_traits<signed char>::const_min)
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
(MinValue >= ::boost::integer_traits<boost::long_long_type>::const_min) +
#else
1 +
#endif
(MinValue >= ::boost::integer_traits<long>::const_min) +
(MinValue >= ::boost::integer_traits<int>::const_min) +
(MinValue >= ::boost::integer_traits<short>::const_min) +
(MinValue >= ::boost::integer_traits<signed char>::const_min)
>::least least;
typedef typename int_fast_t<least>::fast fast;
typedef typename int_fast_t<least>::type fast;
};
// unsigned
template< unsigned long Value > // maximum value to require support
struct uint_value_t
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
template< boost::ulong_long_type MaxValue > // minimum value to require support
#else
template< unsigned long MaxValue > // minimum value to require support
#endif
struct uint_value_t
{
typedef typename int_least_helper
<
5 +
(Value <= integer_traits<unsigned long>::const_max) +
(Value <= integer_traits<unsigned int>::const_max) +
(Value <= integer_traits<unsigned short>::const_max) +
(Value <= integer_traits<unsigned char>::const_max)
#if (defined(BOOST_BORLANDC) || defined(__CODEGEAR__))
// It's really not clear why this workaround should be needed... shrug I guess! JM
#if defined(BOOST_NO_INTEGRAL_INT64_T)
BOOST_STATIC_CONSTANT(unsigned, which =
1 +
(MaxValue <= ::boost::integer_traits<unsigned long>::const_max) +
(MaxValue <= ::boost::integer_traits<unsigned int>::const_max) +
(MaxValue <= ::boost::integer_traits<unsigned short>::const_max) +
(MaxValue <= ::boost::integer_traits<unsigned char>::const_max));
typedef typename detail::int_least_helper< ::boost::uint_value_t<MaxValue>::which>::least least;
#else // BOOST_NO_INTEGRAL_INT64_T
BOOST_STATIC_CONSTANT(unsigned, which =
1 +
(MaxValue <= ::boost::integer_traits<boost::ulong_long_type>::const_max) +
(MaxValue <= ::boost::integer_traits<unsigned long>::const_max) +
(MaxValue <= ::boost::integer_traits<unsigned int>::const_max) +
(MaxValue <= ::boost::integer_traits<unsigned short>::const_max) +
(MaxValue <= ::boost::integer_traits<unsigned char>::const_max));
typedef typename detail::uint_least_helper< ::boost::uint_value_t<MaxValue>::which>::least least;
#endif // BOOST_NO_INTEGRAL_INT64_T
#else
typedef typename boost::detail::uint_least_helper
<
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
(MaxValue <= ::boost::integer_traits<boost::ulong_long_type>::const_max) +
#else
1 +
#endif
(MaxValue <= ::boost::integer_traits<unsigned long>::const_max) +
(MaxValue <= ::boost::integer_traits<unsigned int>::const_max) +
(MaxValue <= ::boost::integer_traits<unsigned short>::const_max) +
(MaxValue <= ::boost::integer_traits<unsigned char>::const_max)
>::least least;
typedef typename int_fast_t<least>::fast fast;
#endif
typedef typename int_fast_t<least>::type fast;
};

View File

@ -0,0 +1,16 @@
// Boost common_factor.hpp header file -------------------------------------//
// (C) Copyright Daryle Walker 2001-2002.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org for updates, documentation, and revision history.
#ifndef BOOST_INTEGER_COMMON_FACTOR_HPP
#define BOOST_INTEGER_COMMON_FACTOR_HPP
#include <boost/integer/common_factor_ct.hpp>
#include <boost/integer/common_factor_rt.hpp>
#endif // BOOST_INTEGER_COMMON_FACTOR_HPP

View File

@ -0,0 +1,102 @@
// Boost common_factor_ct.hpp header file ----------------------------------//
// (C) Copyright Daryle Walker and Stephen Cleary 2001-2002.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org for updates, documentation, and revision history.
#ifndef BOOST_INTEGER_COMMON_FACTOR_CT_HPP
#define BOOST_INTEGER_COMMON_FACTOR_CT_HPP
#include <boost/integer_fwd.hpp> // self include
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT, etc.
namespace boost
{
namespace integer
{
// Implementation details --------------------------------------------------//
namespace detail
{
// Build GCD with Euclid's recursive algorithm
template < static_gcd_type Value1, static_gcd_type Value2 >
struct static_gcd_helper_t
{
private:
BOOST_STATIC_CONSTANT( static_gcd_type, new_value1 = Value2 );
BOOST_STATIC_CONSTANT( static_gcd_type, new_value2 = Value1 % Value2 );
#ifndef BOOST_BORLANDC
#define BOOST_DETAIL_GCD_HELPER_VAL(Value) static_cast<static_gcd_type>(Value)
#else
typedef static_gcd_helper_t self_type;
#define BOOST_DETAIL_GCD_HELPER_VAL(Value) (self_type:: Value )
#endif
typedef static_gcd_helper_t< BOOST_DETAIL_GCD_HELPER_VAL(new_value1),
BOOST_DETAIL_GCD_HELPER_VAL(new_value2) > next_step_type;
#undef BOOST_DETAIL_GCD_HELPER_VAL
public:
BOOST_STATIC_CONSTANT( static_gcd_type, value = next_step_type::value );
};
// Non-recursive case
template < static_gcd_type Value1 >
struct static_gcd_helper_t< Value1, 0UL >
{
BOOST_STATIC_CONSTANT( static_gcd_type, value = Value1 );
};
// Build the LCM from the GCD
template < static_gcd_type Value1, static_gcd_type Value2 >
struct static_lcm_helper_t
{
typedef static_gcd_helper_t<Value1, Value2> gcd_type;
BOOST_STATIC_CONSTANT( static_gcd_type, value = Value1 / gcd_type::value
* Value2 );
};
// Special case for zero-GCD values
template < >
struct static_lcm_helper_t< 0UL, 0UL >
{
BOOST_STATIC_CONSTANT( static_gcd_type, value = 0UL );
};
} // namespace detail
// Compile-time greatest common divisor evaluator class declaration --------//
template < static_gcd_type Value1, static_gcd_type Value2 > struct static_gcd
{
BOOST_STATIC_CONSTANT( static_gcd_type, value = (detail::static_gcd_helper_t<Value1, Value2>::value) );
}; // boost::integer::static_gcd
#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
template< static_gcd_type Value1, static_gcd_type Value2 > static_gcd_type const static_gcd< Value1, Value2 >::value;
#endif
// Compile-time least common multiple evaluator class declaration ----------//
template < static_gcd_type Value1, static_gcd_type Value2 > struct static_lcm
{
BOOST_STATIC_CONSTANT( static_gcd_type, value = (detail::static_lcm_helper_t<Value1, Value2>::value) );
}; // boost::integer::static_lcm
#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
template< static_gcd_type Value1, static_gcd_type Value2 > static_gcd_type const static_lcm< Value1, Value2 >::value;
#endif
} // namespace integer
} // namespace boost
#endif // BOOST_INTEGER_COMMON_FACTOR_CT_HPP

View File

@ -0,0 +1,580 @@
// (C) Copyright Jeremy William Murphy 2016.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_INTEGER_COMMON_FACTOR_RT_HPP
#define BOOST_INTEGER_COMMON_FACTOR_RT_HPP
#include <boost/assert.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/config.hpp> // for BOOST_NESTED_TEMPLATE, etc.
#include <boost/limits.hpp> // for std::numeric_limits
#include <climits> // for CHAR_MIN
#include <boost/detail/workaround.hpp>
#include <iterator>
#include <algorithm>
#include <limits>
#ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS
#include <type_traits>
#endif
#ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
#include <functional>
#endif
#if ((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))
#include <intrin.h>
#endif
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4127 4244) // Conditional expression is constant
#endif
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) && !defined(BOOST_NO_CXX11_NOEXCEPT)
#define BOOST_GCD_NOEXCEPT(T) noexcept(std::is_arithmetic<T>::value)
#else
#define BOOST_GCD_NOEXCEPT(T)
#endif
namespace boost {
template <class I>
class rational;
namespace integer {
namespace gcd_detail{
//
// some helper functions which really should be constexpr already, but sadly aren't:
//
#ifndef BOOST_NO_CXX14_CONSTEXPR
template <class T>
inline constexpr T constexpr_min(T const& a, T const& b) BOOST_GCD_NOEXCEPT(T)
{
return a < b ? a : b;
}
template <class T>
inline constexpr auto constexpr_swap(T&a, T& b) BOOST_GCD_NOEXCEPT(T) -> decltype(a.swap(b))
{
return a.swap(b);
}
template <class T, class U>
inline constexpr void constexpr_swap(T&a, U& b...) BOOST_GCD_NOEXCEPT(T)
{
T t(static_cast<T&&>(a));
a = static_cast<T&&>(b);
b = static_cast<T&&>(t);
}
#else
template <class T>
inline T constexpr_min(T const& a, T const& b) BOOST_GCD_NOEXCEPT(T)
{
return a < b ? a : b;
}
template <class T>
inline void constexpr_swap(T&a, T& b) BOOST_GCD_NOEXCEPT(T)
{
using std::swap;
swap(a, b);
}
#endif
template <class T, bool a =
#ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS
std::is_unsigned<T>::value ||
#endif
(std::numeric_limits<T>::is_specialized && !std::numeric_limits<T>::is_signed)>
struct gcd_traits_abs_defaults
{
inline static BOOST_CXX14_CONSTEXPR const T& abs(const T& val) BOOST_GCD_NOEXCEPT(T) { return val; }
};
template <class T>
struct gcd_traits_abs_defaults<T, false>
{
inline static T BOOST_CXX14_CONSTEXPR abs(const T& val) BOOST_GCD_NOEXCEPT(T)
{
// This sucks, but std::abs is not constexpr :(
return val < T(0) ? -val : val;
}
};
enum method_type
{
method_euclid = 0,
method_binary = 1,
method_mixed = 2
};
struct any_convert
{
template <class T>
any_convert(const T&);
};
struct unlikely_size
{
char buf[9973];
};
unlikely_size operator <<= (any_convert, any_convert);
unlikely_size operator >>= (any_convert, any_convert);
template <class T>
struct gcd_traits_defaults : public gcd_traits_abs_defaults<T>
{
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(T& val) BOOST_GCD_NOEXCEPT(T)
{
unsigned r = 0;
while (T(0) == (val & 1u))
{
#ifdef _MSC_VER // VC++ can't handle operator >>= in constexpr code for some reason
val = val >> 1;
#else
val >>= 1;
#endif
++r;
}
return r;
}
inline static BOOST_CXX14_CONSTEXPR bool less(const T& a, const T& b) BOOST_GCD_NOEXCEPT(T)
{
return a < b;
}
static T& get_value();
#ifndef BOOST_NO_SFINAE
static const bool has_operator_left_shift_equal = sizeof(get_value() <<= 2) != sizeof(unlikely_size);
static const bool has_operator_right_shift_equal = sizeof(get_value() >>= 2) != sizeof(unlikely_size);
#else
static const bool has_operator_left_shift_equal = true;
static const bool has_operator_right_shift_equal = true;
#endif
static const method_type method = std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::is_integer && has_operator_left_shift_equal && has_operator_right_shift_equal ? method_mixed : method_euclid;
};
//
// Default gcd_traits just inherits from defaults:
//
template <class T>
struct gcd_traits : public gcd_traits_defaults<T> {};
//
// Some platforms have fast bitscan operations, that allow us to implement
// make_odd much more efficiently, unfortunately we can't use these if we want
// the functions to be constexpr as the compiler intrinsics aren't constexpr.
//
#if defined(BOOST_NO_CXX14_CONSTEXPR) && ((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))
#pragma intrinsic(_BitScanForward,)
template <>
struct gcd_traits<unsigned long> : public gcd_traits_defaults<unsigned long>
{
BOOST_FORCEINLINE static unsigned find_lsb(unsigned long val) BOOST_NOEXCEPT
{
unsigned long result;
_BitScanForward(&result, val);
return result;
}
BOOST_FORCEINLINE static unsigned make_odd(unsigned long& val) BOOST_NOEXCEPT
{
unsigned result = find_lsb(val);
val >>= result;
return result;
}
};
#ifdef _M_X64
#pragma intrinsic(_BitScanForward64)
template <>
struct gcd_traits<unsigned __int64> : public gcd_traits_defaults<unsigned __int64>
{
BOOST_FORCEINLINE static unsigned find_lsb(unsigned __int64 mask) BOOST_NOEXCEPT
{
unsigned long result;
_BitScanForward64(&result, mask);
return result;
}
BOOST_FORCEINLINE static unsigned make_odd(unsigned __int64& val) BOOST_NOEXCEPT
{
unsigned result = find_lsb(val);
val >>= result;
return result;
}
};
#endif
//
// Other integer type are trivial adaptations of the above,
// this works for signed types too, as by the time these functions
// are called, all values are > 0.
//
template <> struct gcd_traits<long> : public gcd_traits_defaults<long>
{ BOOST_FORCEINLINE static unsigned make_odd(long& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
template <> struct gcd_traits<unsigned int> : public gcd_traits_defaults<unsigned int>
{ BOOST_FORCEINLINE static unsigned make_odd(unsigned int& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
template <> struct gcd_traits<int> : public gcd_traits_defaults<int>
{ BOOST_FORCEINLINE static unsigned make_odd(int& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
template <> struct gcd_traits<unsigned short> : public gcd_traits_defaults<unsigned short>
{ BOOST_FORCEINLINE static unsigned make_odd(unsigned short& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
template <> struct gcd_traits<short> : public gcd_traits_defaults<short>
{ BOOST_FORCEINLINE static unsigned make_odd(short& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
template <> struct gcd_traits<unsigned char> : public gcd_traits_defaults<unsigned char>
{ BOOST_FORCEINLINE static unsigned make_odd(unsigned char& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
template <> struct gcd_traits<signed char> : public gcd_traits_defaults<signed char>
{ BOOST_FORCEINLINE static unsigned make_odd(signed char& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
template <> struct gcd_traits<char> : public gcd_traits_defaults<char>
{ BOOST_FORCEINLINE static unsigned make_odd(char& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template <> struct gcd_traits<wchar_t> : public gcd_traits_defaults<wchar_t>
{ BOOST_FORCEINLINE static unsigned make_odd(wchar_t& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
#endif
#ifdef _M_X64
template <> struct gcd_traits<__int64> : public gcd_traits_defaults<__int64>
{ BOOST_FORCEINLINE static unsigned make_odd(__int64& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned __int64>::find_lsb(val); val >>= result; return result; } };
#endif
#elif defined(BOOST_GCC) || defined(__clang__) || (defined(BOOST_INTEL) && defined(__GNUC__))
template <>
struct gcd_traits<unsigned> : public gcd_traits_defaults<unsigned>
{
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned find_lsb(unsigned mask)BOOST_NOEXCEPT
{
return __builtin_ctz(mask);
}
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(unsigned& val)BOOST_NOEXCEPT
{
unsigned result = find_lsb(val);
val >>= result;
return result;
}
};
template <>
struct gcd_traits<unsigned long> : public gcd_traits_defaults<unsigned long>
{
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned find_lsb(unsigned long mask)BOOST_NOEXCEPT
{
return __builtin_ctzl(mask);
}
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(unsigned long& val)BOOST_NOEXCEPT
{
unsigned result = find_lsb(val);
val >>= result;
return result;
}
};
template <>
struct gcd_traits<boost::ulong_long_type> : public gcd_traits_defaults<boost::ulong_long_type>
{
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned find_lsb(boost::ulong_long_type mask)BOOST_NOEXCEPT
{
return __builtin_ctzll(mask);
}
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(boost::ulong_long_type& val)BOOST_NOEXCEPT
{
unsigned result = find_lsb(val);
val >>= result;
return result;
}
};
//
// Other integer type are trivial adaptations of the above,
// this works for signed types too, as by the time these functions
// are called, all values are > 0.
//
template <> struct gcd_traits<boost::long_long_type> : public gcd_traits_defaults<boost::long_long_type>
{
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(boost::long_long_type& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<boost::ulong_long_type>::find_lsb(val); val >>= result; return result; }
};
template <> struct gcd_traits<long> : public gcd_traits_defaults<long>
{
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(long& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; }
};
template <> struct gcd_traits<int> : public gcd_traits_defaults<int>
{
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(int& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; }
};
template <> struct gcd_traits<unsigned short> : public gcd_traits_defaults<unsigned short>
{
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(unsigned short& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
};
template <> struct gcd_traits<short> : public gcd_traits_defaults<short>
{
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(short& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
};
template <> struct gcd_traits<unsigned char> : public gcd_traits_defaults<unsigned char>
{
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(unsigned char& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
};
template <> struct gcd_traits<signed char> : public gcd_traits_defaults<signed char>
{
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(signed char& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
};
template <> struct gcd_traits<char> : public gcd_traits_defaults<char>
{
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(char& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
};
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template <> struct gcd_traits<wchar_t> : public gcd_traits_defaults<wchar_t>
{
BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(wchar_t& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
};
#endif
#endif
//
// The Mixed Binary Euclid Algorithm
// Sidi Mohamed Sedjelmaci
// Electronic Notes in Discrete Mathematics 35 (2009) 169-176
//
template <class T>
BOOST_CXX14_CONSTEXPR T mixed_binary_gcd(T u, T v) BOOST_GCD_NOEXCEPT(T)
{
if(gcd_traits<T>::less(u, v))
constexpr_swap(u, v);
unsigned shifts = 0;
if(u == T(0))
return v;
if(v == T(0))
return u;
shifts = constexpr_min(gcd_traits<T>::make_odd(u), gcd_traits<T>::make_odd(v));
while(gcd_traits<T>::less(1, v))
{
u %= v;
v -= u;
if(u == T(0))
return v << shifts;
if(v == T(0))
return u << shifts;
gcd_traits<T>::make_odd(u);
gcd_traits<T>::make_odd(v);
if(gcd_traits<T>::less(u, v))
constexpr_swap(u, v);
}
return (v == 1 ? v : u) << shifts;
}
/** Stein gcd (aka 'binary gcd')
*
* From Mathematics to Generic Programming, Alexander Stepanov, Daniel Rose
*/
template <typename SteinDomain>
BOOST_CXX14_CONSTEXPR SteinDomain Stein_gcd(SteinDomain m, SteinDomain n) BOOST_GCD_NOEXCEPT(SteinDomain)
{
BOOST_ASSERT(m >= 0);
BOOST_ASSERT(n >= 0);
if (m == SteinDomain(0))
return n;
if (n == SteinDomain(0))
return m;
// m > 0 && n > 0
unsigned d_m = gcd_traits<SteinDomain>::make_odd(m);
unsigned d_n = gcd_traits<SteinDomain>::make_odd(n);
// odd(m) && odd(n)
while (m != n)
{
if (n > m)
constexpr_swap(n, m);
m -= n;
gcd_traits<SteinDomain>::make_odd(m);
}
// m == n
m <<= constexpr_min(d_m, d_n);
return m;
}
/** Euclidean algorithm
*
* From Mathematics to Generic Programming, Alexander Stepanov, Daniel Rose
*
*/
template <typename EuclideanDomain>
inline BOOST_CXX14_CONSTEXPR EuclideanDomain Euclid_gcd(EuclideanDomain a, EuclideanDomain b) BOOST_GCD_NOEXCEPT(EuclideanDomain)
{
while (b != EuclideanDomain(0))
{
a %= b;
constexpr_swap(a, b);
}
return a;
}
template <typename T>
inline BOOST_CXX14_CONSTEXPR BOOST_DEDUCED_TYPENAME enable_if_c<gcd_traits<T>::method == method_mixed, T>::type
optimal_gcd_select(T const &a, T const &b) BOOST_GCD_NOEXCEPT(T)
{
return gcd_detail::mixed_binary_gcd(a, b);
}
template <typename T>
inline BOOST_CXX14_CONSTEXPR BOOST_DEDUCED_TYPENAME enable_if_c<gcd_traits<T>::method == method_binary, T>::type
optimal_gcd_select(T const &a, T const &b) BOOST_GCD_NOEXCEPT(T)
{
return gcd_detail::Stein_gcd(a, b);
}
template <typename T>
inline BOOST_CXX14_CONSTEXPR BOOST_DEDUCED_TYPENAME enable_if_c<gcd_traits<T>::method == method_euclid, T>::type
optimal_gcd_select(T const &a, T const &b) BOOST_GCD_NOEXCEPT(T)
{
return gcd_detail::Euclid_gcd(a, b);
}
template <class T>
inline BOOST_CXX14_CONSTEXPR T lcm_imp(const T& a, const T& b) BOOST_GCD_NOEXCEPT(T)
{
T temp = boost::integer::gcd_detail::optimal_gcd_select(a, b);
#if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40500)
return (temp != T(0)) ? T(a / temp * b) : T(0);
#else
return temp != T(0) ? T(a / temp * b) : T(0);
#endif
}
} // namespace detail
template <typename Integer>
inline BOOST_CXX14_CONSTEXPR Integer gcd(Integer const &a, Integer const &b) BOOST_GCD_NOEXCEPT(Integer)
{
if(a == (std::numeric_limits<Integer>::min)())
return a == static_cast<Integer>(0) ? gcd_detail::gcd_traits<Integer>::abs(b) : boost::integer::gcd(static_cast<Integer>(a % b), b);
else if (b == (std::numeric_limits<Integer>::min)())
return b == static_cast<Integer>(0) ? gcd_detail::gcd_traits<Integer>::abs(a) : boost::integer::gcd(a, static_cast<Integer>(b % a));
return gcd_detail::optimal_gcd_select(static_cast<Integer>(gcd_detail::gcd_traits<Integer>::abs(a)), static_cast<Integer>(gcd_detail::gcd_traits<Integer>::abs(b)));
}
template <typename Integer>
inline BOOST_CXX14_CONSTEXPR Integer lcm(Integer const &a, Integer const &b) BOOST_GCD_NOEXCEPT(Integer)
{
return gcd_detail::lcm_imp(static_cast<Integer>(gcd_detail::gcd_traits<Integer>::abs(a)), static_cast<Integer>(gcd_detail::gcd_traits<Integer>::abs(b)));
}
#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
//
// This looks slightly odd, but the variadic forms must have 3 or more arguments, and the variadic argument pack may be empty.
// This matters not at all for most compilers, but Oracle C++ selects the wrong overload in the 2-arg case unless we do this.
//
template <typename Integer, typename... Args>
inline BOOST_CXX14_CONSTEXPR Integer gcd(Integer const &a, Integer const &b, const Integer& c, Args const&... args) BOOST_GCD_NOEXCEPT(Integer)
{
Integer t = gcd(b, c, args...);
return t == 1 ? 1 : gcd(a, t);
}
template <typename Integer, typename... Args>
inline BOOST_CXX14_CONSTEXPR Integer lcm(Integer const &a, Integer const &b, Integer const& c, Args const&... args) BOOST_GCD_NOEXCEPT(Integer)
{
return lcm(a, lcm(b, c, args...));
}
#endif
//
// Special handling for rationals:
//
template <typename Integer>
inline typename boost::enable_if_c<std::numeric_limits<Integer>::is_specialized, boost::rational<Integer> >::type gcd(boost::rational<Integer> const &a, boost::rational<Integer> const &b)
{
return boost::rational<Integer>(static_cast<Integer>(gcd(a.numerator(), b.numerator())), static_cast<Integer>(lcm(a.denominator(), b.denominator())));
}
template <typename Integer>
inline typename boost::enable_if_c<std::numeric_limits<Integer>::is_specialized, boost::rational<Integer> >::type lcm(boost::rational<Integer> const &a, boost::rational<Integer> const &b)
{
return boost::rational<Integer>(static_cast<Integer>(lcm(a.numerator(), b.numerator())), static_cast<Integer>(gcd(a.denominator(), b.denominator())));
}
/**
* Knuth, The Art of Computer Programming: Volume 2, Third edition, 1998
* Chapter 4.5.2, Algorithm C: Greatest common divisor of n integers.
*
* Knuth counts down from n to zero but we naturally go from first to last.
* We also return the termination position because it might be useful to know.
*
* Partly by quirk, partly by design, this algorithm is defined for n = 1,
* because the gcd of {x} is x. It is not defined for n = 0.
*
* @tparam I Input iterator.
* @return The gcd of the range and the iterator position at termination.
*/
template <typename I>
std::pair<typename std::iterator_traits<I>::value_type, I>
gcd_range(I first, I last) BOOST_GCD_NOEXCEPT(I)
{
BOOST_ASSERT(first != last);
typedef typename std::iterator_traits<I>::value_type T;
T d = *first;
++first;
while (d != T(1) && first != last)
{
d = gcd(d, *first);
++first;
}
return std::make_pair(d, first);
}
template <typename I>
std::pair<typename std::iterator_traits<I>::value_type, I>
lcm_range(I first, I last) BOOST_GCD_NOEXCEPT(I)
{
BOOST_ASSERT(first != last);
typedef typename std::iterator_traits<I>::value_type T;
T d = *first;
++first;
while (d != T(0) && first != last)
{
d = lcm(d, *first);
++first;
}
return std::make_pair(d, first);
}
template < typename IntegerType >
class gcd_evaluator
#ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
: public std::binary_function<IntegerType, IntegerType, IntegerType>
#endif
{
public:
#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
typedef IntegerType first_argument_type;
typedef IntegerType second_argument_type;
typedef IntegerType result_type;
#endif
IntegerType operator()(IntegerType const &a, IntegerType const &b) const
{
return boost::integer::gcd(a, b);
}
};
template < typename IntegerType >
class lcm_evaluator
#ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
: public std::binary_function<IntegerType, IntegerType, IntegerType>
#endif
{
public:
#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
typedef IntegerType first_argument_type;
typedef IntegerType second_argument_type;
typedef IntegerType result_type;
#endif
IntegerType operator()(IntegerType const &a, IntegerType const &b)const
{
return boost::integer::lcm(a, b);
}
};
} // namespace integer
} // namespace boost
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
#endif // BOOST_INTEGER_COMMON_FACTOR_RT_HPP

View File

@ -0,0 +1,83 @@
/*
* (C) Copyright Nick Thompson 2018.
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_INTEGER_EXTENDED_EUCLIDEAN_HPP
#define BOOST_INTEGER_EXTENDED_EUCLIDEAN_HPP
#include <limits>
#include <stdexcept>
#include <boost/throw_exception.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/enable_if.hpp>
namespace boost { namespace integer {
// From "The Joy of Factoring", Algorithm 2.7, with a small optimization to remove tmps from Wikipedia.
// Solves mx + ny = gcd(m,n). Returns tuple with (gcd(m,n), x, y).
template<class Z>
struct euclidean_result_t
{
Z gcd;
Z x;
Z y;
};
template<class Z>
typename boost::enable_if_c< std::numeric_limits< Z >::is_signed, euclidean_result_t< Z > >::type
extended_euclidean(Z m, Z n)
{
if (m < 1 || n < 1)
{
BOOST_THROW_EXCEPTION(std::domain_error("extended_euclidean: arguments must be strictly positive"));
}
bool swapped = false;
if (m < n)
{
swapped = true;
boost::core::invoke_swap(m, n);
}
Z u0 = m;
Z u1 = 1;
Z u2 = 0;
Z v0 = n;
Z v1 = 0;
Z v2 = 1;
Z w0;
Z w1;
Z w2;
while(v0 > 0)
{
Z q = u0/v0;
w0 = u0 - q*v0;
w1 = u1 - q*v1;
w2 = u2 - q*v2;
u0 = v0;
u1 = v1;
u2 = v2;
v0 = w0;
v1 = w1;
v2 = w2;
}
euclidean_result_t< Z > result;
result.gcd = u0;
if (!swapped)
{
result.x = u1;
result.y = u2;
}
else
{
result.x = u2;
result.y = u1;
}
return result;
}
}}
#endif

View File

@ -0,0 +1,117 @@
// -----------------------------------------------------------
// integer_log2.hpp
//
// Gives the integer part of the logarithm, in base 2, of a
// given number. Behavior is undefined if the argument is <= 0.
//
// Copyright (c) 2003-2004, 2008 Gennaro Prota
// Copyright (c) 2022 Andrey Semashev
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
//
// -----------------------------------------------------------
#ifndef BOOST_INTEGER_INTEGER_LOG2_HPP
#define BOOST_INTEGER_INTEGER_LOG2_HPP
#include <climits>
#include <limits>
#include <boost/config.hpp>
#include <boost/assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/core/bit.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/make_unsigned.hpp>
namespace boost {
namespace detail {
// helper to find the maximum power of two
// less than p
template< unsigned int p, unsigned int n, bool = ((2u * n) < p) >
struct max_pow2_less :
public max_pow2_less< p, 2u * n >
{
};
template< unsigned int p, unsigned int n >
struct max_pow2_less< p, n, false >
{
BOOST_STATIC_CONSTANT(unsigned int, value = n);
};
template< typename T >
inline typename boost::disable_if< boost::is_integral< T >, int >::type integer_log2_impl(T x)
{
unsigned int n = detail::max_pow2_less<
std::numeric_limits< T >::digits,
CHAR_BIT / 2u
>::value;
int result = 0;
while (x != 1)
{
T t(x >> n);
if (t)
{
result += static_cast< int >(n);
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
x = static_cast< T&& >(t);
#else
x = t;
#endif
}
n >>= 1u;
}
return result;
}
template< typename T >
inline typename boost::enable_if< boost::is_integral< T >, int >::type integer_log2_impl(T x)
{
// We could simply rely on numeric_limits but sometimes
// Borland tries to use numeric_limits<const T>, because
// of its usual const-related problems in argument deduction
// - gps
return static_cast< int >((sizeof(T) * CHAR_BIT - 1u) -
boost::core::countl_zero(static_cast< typename boost::make_unsigned< T >::type >(x)));
}
#if defined(BOOST_HAS_INT128)
// We need to provide explicit overloads for __int128 because (a) boost/core/bit.hpp currently does not support it and
// (b) std::numeric_limits are not specialized for __int128 in some standard libraries.
inline int integer_log2_impl(boost::uint128_type x)
{
const boost::uint64_t x_hi = static_cast< boost::uint64_t >(x >> 64u);
if (x_hi != 0u)
return 127 - boost::core::countl_zero(x_hi);
else
return 63 - boost::core::countl_zero(static_cast< boost::uint64_t >(x));
}
inline int integer_log2_impl(boost::int128_type x)
{
return detail::integer_log2_impl(static_cast< boost::uint128_type >(x));
}
#endif // defined(BOOST_HAS_INT128)
} // namespace detail
// ------------
// integer_log2
// ------------
template< typename T >
inline int integer_log2(T x)
{
BOOST_ASSERT(x > 0);
return detail::integer_log2_impl(x);
}
} // namespace boost
#endif // BOOST_INTEGER_INTEGER_LOG2_HPP

View File

@ -1,11 +1,11 @@
// Boost integer/integer_mask.hpp header file ------------------------------//
// (C) Copyright Daryle Walker 2001. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or
// implied warranty, and with no claim as to its suitability for any purpose.
// (C) Copyright Daryle Walker 2001.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
// See https://www.boost.org for updates, documentation, and revision history.
#ifndef BOOST_INTEGER_INTEGER_MASK_HPP
#define BOOST_INTEGER_INTEGER_MASK_HPP
@ -20,6 +20,17 @@
#include <boost/limits.hpp> // for std::numeric_limits
//
// We simply cannot include this header on gcc without getting copious warnings of the kind:
//
// boost/integer/integer_mask.hpp:93:35: warning: use of C99 long long integer constant
//
// And yet there is no other reasonable implementation, so we declare this a system header
// to suppress these warnings.
//
#if defined(__GNUC__) && (__GNUC__ >= 4)
#pragma GCC system_header
#endif
namespace boost
{
@ -46,19 +57,27 @@ struct high_bit_mask_t
// Makes masks for the lowest N bits
// (Specializations are needed when N fills up a type.)
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4310) // cast truncates constant value
#endif
template < std::size_t Bits >
struct low_bits_mask_t
{
typedef typename uint_t<Bits>::least least;
typedef typename uint_t<Bits>::fast fast;
BOOST_STATIC_CONSTANT( least, sig_bits = (~( ~(least( 0u )) << Bits )) );
BOOST_STATIC_CONSTANT( least, sig_bits = least(~(least(~(least( 0u ))) << Bits )) );
BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) );
BOOST_STATIC_CONSTANT( std::size_t, bit_count = Bits );
}; // boost::low_bits_mask_t
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
#define BOOST_LOW_BITS_MASK_SPECIALIZE( Type ) \
template < > struct low_bits_mask_t< std::numeric_limits<Type>::digits > { \
@ -70,6 +89,11 @@ struct low_bits_mask_t
BOOST_STATIC_CONSTANT( std::size_t, bit_count = limits_type::digits ); \
}
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4245) // 'initializing' : conversion from 'int' to 'const boost::low_bits_mask_t<8>::least', signed/unsigned mismatch
#endif
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned char );
#if USHRT_MAX > UCHAR_MAX
@ -84,6 +108,23 @@ BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned int );
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned long );
#endif
#if defined(BOOST_HAS_LONG_LONG)
#if ((defined(ULLONG_MAX) && (ULLONG_MAX > ULONG_MAX)) ||\
(defined(ULONG_LONG_MAX) && (ULONG_LONG_MAX > ULONG_MAX)) ||\
(defined(ULONGLONG_MAX) && (ULONGLONG_MAX > ULONG_MAX)) ||\
(defined(_ULLONG_MAX) && (_ULLONG_MAX > ULONG_MAX)))
BOOST_LOW_BITS_MASK_SPECIALIZE( boost::ulong_long_type );
#endif
#elif defined(BOOST_HAS_MS_INT64)
#if 18446744073709551615ui64 > ULONG_MAX
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned __int64 );
#endif
#endif
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
#undef BOOST_LOW_BITS_MASK_SPECIALIZE

View File

@ -0,0 +1,53 @@
/*
* (C) Copyright Nick Thompson 2018.
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_INTEGER_MOD_INVERSE_HPP
#define BOOST_INTEGER_MOD_INVERSE_HPP
#include <stdexcept>
#include <boost/throw_exception.hpp>
#include <boost/integer/extended_euclidean.hpp>
namespace boost { namespace integer {
// From "The Joy of Factoring", Algorithm 2.7.
// Here's some others names I've found for this function:
// PowerMod[a, -1, m] (Mathematica)
// mpz_invert (gmplib)
// modinv (some dude on stackoverflow)
// Would mod_inverse be sometimes mistaken as the modular *additive* inverse?
// In any case, I think this is the best name we can get for this function without agonizing.
template<class Z>
Z mod_inverse(Z a, Z modulus)
{
if (modulus < Z(2))
{
BOOST_THROW_EXCEPTION(std::domain_error("mod_inverse: modulus must be > 1"));
}
// make sure a < modulus:
a = a % modulus;
if (a == Z(0))
{
// a doesn't have a modular multiplicative inverse:
return Z(0);
}
boost::integer::euclidean_result_t<Z> u = boost::integer::extended_euclidean(a, modulus);
if (u.gcd > Z(1))
{
return Z(0);
}
// x might not be in the range 0 < x < m, let's fix that:
while (u.x <= Z(0))
{
u.x += modulus;
}
// While indeed this is an inexpensive and comforting check,
// the multiplication overflows and hence makes the check itself buggy.
//BOOST_ASSERT(u.x*a % modulus == 1);
return u.x;
}
}}
#endif

View File

@ -1,141 +1,126 @@
// Boost integer/static_log2.hpp header file -------------------------------//
// -------------- Boost static_log2.hpp header file ----------------------- //
//
// Copyright (C) 2001 Daryle Walker.
// Copyright (C) 2003 Vesa Karvonen.
// Copyright (C) 2003 Gennaro Prota.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
//
// ---------------------------------------------------
// See https://www.boost.org/libs/integer for documentation.
// ------------------------------------------------------------------------- //
// (C) Copyright Daryle Walker 2001. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or
// implied warranty, and with no claim as to its suitability for any purpose.
// See http://www.boost.org for updates, documentation, and revision history.
#ifndef BOOST_INTEGER_STATIC_LOG2_HPP
#define BOOST_INTEGER_STATIC_LOG2_HPP
#include <boost/integer_fwd.hpp> // self include
#include <boost/config.hpp>
#include <boost/integer_fwd.hpp>
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT, etc.
#include <boost/limits.hpp> // for std::numeric_limits
namespace boost {
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#include <boost/pending/ct_if.hpp> // for boost::ct_if<>
#endif
namespace detail {
namespace static_log2_impl {
// choose_initial_n<>
//
// Recursively doubles its integer argument, until it
// becomes >= of the "width" (C99, 6.2.6.2p4) of
// static_log2_argument_type.
//
// Used to get the maximum power of two less then the width.
//
// Example: if on your platform argument_type has 48 value
// bits it yields n=32.
//
// It's easy to prove that, starting from such a value
// of n, the core algorithm works correctly for any width
// of static_log2_argument_type and that recursion always
// terminates with x = 1 and n = 0 (see the algorithm's
// invariant).
typedef boost::static_log2_argument_type argument_type;
typedef boost::static_log2_result_type result_type;
template <result_type n>
struct choose_initial_n {
BOOST_STATIC_CONSTANT(bool, c = (argument_type(1) << n << n) != 0);
BOOST_STATIC_CONSTANT(
result_type,
value = !c*n + choose_initial_n<2*c*n>::value
);
};
template <>
struct choose_initial_n<0> {
BOOST_STATIC_CONSTANT(result_type, value = 0);
};
namespace boost
{
// start computing from n_zero - must be a power of two
const result_type n_zero = 16;
const result_type initial_n = choose_initial_n<n_zero>::value;
// static_log2_impl<>
//
// * Invariant:
// 2n
// 1 <= x && x < 2 at the start of each recursion
// (see also choose_initial_n<>)
//
// * Type requirements:
//
// argument_type maybe any unsigned type with at least n_zero + 1
// value bits. (Note: If larger types will be standardized -e.g.
// unsigned long long- then the argument_type typedef can be
// changed without affecting the rest of the code.)
//
template <argument_type x, result_type n = initial_n>
struct static_log2_impl {
BOOST_STATIC_CONSTANT(bool, c = (x >> n) > 0); // x >= 2**n ?
BOOST_STATIC_CONSTANT(
result_type,
value = c*n + (static_log2_impl< (x>>c*n), n/2 >::value)
);
};
template <>
struct static_log2_impl<1, 0> {
BOOST_STATIC_CONSTANT(result_type, value = 0);
};
}
} // detail
// Implementation details --------------------------------------------------//
namespace detail
{
// --------------------------------------
// static_log2<x>
// ----------------------------------------
// Forward declarations
template < unsigned long Val, int Place = 0, int Index
= std::numeric_limits<unsigned long>::digits >
struct static_log2_helper_t;
template <static_log2_argument_type x>
struct static_log2 {
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
BOOST_STATIC_CONSTANT(
static_log2_result_type,
value = detail::static_log2_impl::static_log2_impl<x>::value
);
template < unsigned long Val, int Place >
struct static_log2_helper_t< Val, Place, 1 >;
#else
template < int Place >
struct static_log2_helper_final_step;
template < unsigned long Val, int Place = 0, int Index
= std::numeric_limits<unsigned long>::digits >
struct static_log2_helper_nopts_t;
#endif
// Recursively build the logarithm by examining the upper bits
template < unsigned long Val, int Place, int Index >
struct static_log2_helper_t
{
private:
BOOST_STATIC_CONSTANT( int, half_place = Index / 2 );
BOOST_STATIC_CONSTANT( unsigned long, lower_mask = (1ul << half_place)
- 1ul );
BOOST_STATIC_CONSTANT( unsigned long, upper_mask = ~lower_mask );
BOOST_STATIC_CONSTANT( bool, do_shift = (Val & upper_mask) != 0ul );
BOOST_STATIC_CONSTANT( unsigned long, new_val = do_shift ? (Val
>> half_place) : Val );
BOOST_STATIC_CONSTANT( int, new_place = do_shift ? (Place + half_place)
: Place );
BOOST_STATIC_CONSTANT( int, new_index = Index - half_place );
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
typedef static_log2_helper_t<new_val, new_place, new_index> next_step_type;
#else
typedef static_log2_helper_nopts_t<new_val, new_place, new_index> next_step_type;
#endif
public:
BOOST_STATIC_CONSTANT( int, value = next_step_type::value );
}; // boost::detail::static_log2_helper_t
// Non-recursive case
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template < unsigned long Val, int Place >
struct static_log2_helper_t< Val, Place, 1 >
{
public:
BOOST_STATIC_CONSTANT( int, value = Place );
}; // boost::detail::static_log2_helper_t
#else
template < int Place >
struct static_log2_helper_final_step
{
public:
BOOST_STATIC_CONSTANT( int, value = Place );
}; // boost::detail::static_log2_helper_final_step
template < unsigned long Val, int Place, int Index >
struct static_log2_helper_nopts_t
{
private:
typedef static_log2_helper_t<Val, Place, Index> recursive_step_type;
typedef static_log2_helper_final_step<Place> final_step_type;
typedef typename ct_if<( Index != 1 ), recursive_step_type,
final_step_type>::type next_step_type;
public:
BOOST_STATIC_CONSTANT( int, value = next_step_type::value );
}; // boost::detail::static_log2_helper_nopts_t
#endif
} // namespace detail
};
// Compile-time log-base-2 evaluator class declaration ---------------------//
template <>
struct static_log2<0> { };
template < unsigned long Value >
struct static_log2
{
BOOST_STATIC_CONSTANT( int, value
= detail::static_log2_helper_t<Value>::value );
};
}
template < >
struct static_log2< 0ul >
{
// The logarithm of zero is undefined.
};
} // namespace boost
#endif // BOOST_INTEGER_STATIC_LOG2_HPP
#endif // include guard

View File

@ -1,51 +1,47 @@
// Boost integer/static_min_max.hpp header file ----------------------------//
// (C) Copyright Daryle Walker 2001. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright notice
// appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability
// for any purpose.
// (C) Copyright Daryle Walker 2001.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
// See https://www.boost.org for updates, documentation, and revision history.
#ifndef BOOST_INTEGER_STATIC_MIN_MAX_HPP
#define BOOST_INTEGER_STATIC_MIN_MAX_HPP
#include <boost/config.hpp>
#include <boost/integer_fwd.hpp> // self include
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
namespace boost
{
// Compile-time extrema class declarations ---------------------------------//
// Get the minimum or maximum of two values, signed or unsigned.
template < long Value1, long Value2 >
template <static_min_max_signed_type Value1, static_min_max_signed_type Value2>
struct static_signed_min
{
BOOST_STATIC_CONSTANT( long, value = (Value1 > Value2) ? Value2 : Value1 );
BOOST_STATIC_CONSTANT(static_min_max_signed_type, value = (Value1 > Value2) ? Value2 : Value1 );
};
template < long Value1, long Value2 >
template <static_min_max_signed_type Value1, static_min_max_signed_type Value2>
struct static_signed_max
{
BOOST_STATIC_CONSTANT( long, value = (Value1 < Value2) ? Value2 : Value1 );
BOOST_STATIC_CONSTANT(static_min_max_signed_type, value = (Value1 < Value2) ? Value2 : Value1 );
};
template < unsigned long Value1, unsigned long Value2 >
template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
struct static_unsigned_min
{
BOOST_STATIC_CONSTANT( unsigned long, value
BOOST_STATIC_CONSTANT(static_min_max_unsigned_type, value
= (Value1 > Value2) ? Value2 : Value1 );
};
template < unsigned long Value1, unsigned long Value2 >
template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
struct static_unsigned_max
{
BOOST_STATIC_CONSTANT( unsigned long, value
BOOST_STATIC_CONSTANT(static_min_max_unsigned_type, value
= (Value1 < Value2) ? Value2 : Value1 );
};

View File

@ -1,12 +1,10 @@
// Boost integer_fwd.hpp header file ---------------------------------------//
// (C) Copyright boost.org 2001. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// (C) Copyright Dave Abrahams and Daryle Walker 2001. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for most recent version including documentation.
// See https://www.boost.org/libs/integer for documentation.
#ifndef BOOST_INTEGER_FWD_HPP
#define BOOST_INTEGER_FWD_HPP
@ -16,11 +14,23 @@
#include <boost/config.hpp> // for BOOST_NO_INTRINSIC_WCHAR_T
#include <boost/limits.hpp> // for std::numeric_limits
#include <boost/cstdint.hpp> // For intmax_t
namespace boost
{
#ifdef BOOST_NO_INTEGRAL_INT64_T
typedef unsigned long static_log2_argument_type;
typedef int static_log2_result_type;
typedef long static_min_max_signed_type;
typedef unsigned long static_min_max_unsigned_type;
#else
typedef boost::uintmax_t static_min_max_unsigned_type;
typedef boost::intmax_t static_min_max_signed_type;
typedef boost::uintmax_t static_log2_argument_type;
typedef int static_log2_result_type;
#endif
// From <boost/cstdint.hpp> ------------------------------------------------//
@ -67,12 +77,18 @@ template < >
template < >
class integer_traits< unsigned long >;
#ifdef ULLONG_MAX
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
template < >
class integer_traits< long long >;
class integer_traits< ::boost::long_long_type>;
template < >
class integer_traits< unsigned long long >;
class integer_traits< ::boost::ulong_long_type >;
#elif !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_MS_INT64)
template < >
class integer_traits<__int64>;
template < >
class integer_traits<unsigned __int64>;
#endif
@ -87,13 +103,25 @@ template< int Bits >
template< int Bits >
struct uint_t;
template< long MaxValue >
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
template< boost::long_long_type MaxValue > // maximum value to require support
#else
template< long MaxValue > // maximum value to require support
#endif
struct int_max_value_t;
template< long MinValue >
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
template< boost::long_long_type MinValue > // minimum value to require support
#else
template< long MinValue > // minimum value to require support
#endif
struct int_min_value_t;
template< unsigned long Value >
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
template< boost::ulong_long_type MaxValue > // maximum value to require support
#else
template< unsigned long MaxValue > // maximum value to require support
#endif
struct uint_value_t;
@ -108,46 +136,54 @@ template < std::size_t Bits >
template < >
struct low_bits_mask_t< ::std::numeric_limits<unsigned char>::digits >;
#if USHRT_MAX > UCHAR_MAX
template < >
struct low_bits_mask_t< ::std::numeric_limits<unsigned short>::digits >;
#endif
#if UINT_MAX > USHRT_MAX
template < >
struct low_bits_mask_t< ::std::numeric_limits<unsigned int>::digits >;
#endif
#if ULONG_MAX > UINT_MAX
template < >
struct low_bits_mask_t< ::std::numeric_limits<unsigned long>::digits >;
#endif
// From <boost/integer/static_log2.hpp> ------------------------------------//
template < unsigned long Value >
template <static_log2_argument_type Value >
struct static_log2;
template < >
struct static_log2< 0ul >;
template <> struct static_log2<0u>;
// From <boost/integer/static_min_max.hpp> ---------------------------------//
template < long Value1, long Value2 >
template <static_min_max_signed_type Value1, static_min_max_signed_type Value2>
struct static_signed_min;
template < long Value1, long Value2 >
template <static_min_max_signed_type Value1, static_min_max_signed_type Value2>
struct static_signed_max;
template < unsigned long Value1, unsigned long Value2 >
template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
struct static_unsigned_min;
template < unsigned long Value1, unsigned long Value2 >
template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
struct static_unsigned_max;
namespace integer
{
// From <boost/integer/common_factor_ct.hpp>
#ifdef BOOST_NO_INTEGRAL_INT64_T
typedef unsigned long static_gcd_type;
#else
typedef boost::uintmax_t static_gcd_type;
#endif
template < static_gcd_type Value1, static_gcd_type Value2 >
struct static_gcd;
template < static_gcd_type Value1, static_gcd_type Value2 >
struct static_lcm;
// From <boost/integer/common_factor_rt.hpp>
template < typename IntegerType >
class gcd_evaluator;
template < typename IntegerType >
class lcm_evaluator;
} // namespace integer
} // namespace boost

View File

@ -1,20 +1,18 @@
/* boost integer_traits.hpp header file
*
* Copyright Jens Maurer 2000
* Permission to use, copy, modify, sell, and distribute this software
* is hereby granted without fee provided that the above copyright notice
* appears in all copies and that both that copyright notice and this
* permission notice appear in supporting documentation,
*
* Jens Maurer makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* https://www.boost.org/LICENSE_1_0.txt)
*
* $Id$
*
* Idea by Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers
*/
// See https://www.boost.org/libs/integer for documentation.
#ifndef BOOST_INTEGER_TRAITS_HPP
#define BOOST_INTEGER_TRAITS_HPP
@ -23,10 +21,23 @@
// These are an implementation detail and not part of the interface
#include <limits.h>
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) && !defined(BOOST_NO_CWCHAR)
// we need wchar.h for WCHAR_MAX/MIN but not all platforms provide it,
// and some may have <wchar.h> but not <cwchar> ...
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) && (!defined(BOOST_NO_CWCHAR) || defined(sun) || defined(__sun) || defined(__QNX__))
#include <wchar.h>
#endif
//
// We simply cannot include this header on gcc without getting copious warnings of the kind:
//
// ../../../boost/integer_traits.hpp:164:66: warning: use of C99 long long integer constant
//
// And yet there is no other reasonable implementation, so we declare this a system header
// to suppress these warnings.
//
#if defined(__GNUC__) && (__GNUC__ >= 4)
#pragma GCC system_header
#endif
namespace boost {
template<class T>
@ -88,23 +99,26 @@ class integer_traits<unsigned char>
template<>
class integer_traits<wchar_t>
: public std::numeric_limits<wchar_t>,
#if defined(WCHAR_MIN) && defined(WCHAR_MAX)
// Don't trust WCHAR_MIN and WCHAR_MAX with Mac OS X's native
// library: they are wrong!
#if defined(WCHAR_MIN) && defined(WCHAR_MAX) && !defined(__APPLE__)
public detail::integer_traits_base<wchar_t, WCHAR_MIN, WCHAR_MAX>
#elif defined(__BORLANDC__) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__BEOS__) && defined(__GNUC__))
#elif defined(BOOST_BORLANDC) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__BEOS__) && defined(__GNUC__))
// No WCHAR_MIN and WCHAR_MAX, whar_t is short and unsigned:
public detail::integer_traits_base<wchar_t, 0, 0xffff>
#elif (defined(__sgi) && (!defined(__SGI_STL_PORT) || __SGI_STL_PORT < 0x400)) || (defined __APPLE__) || (defined(__FreeBSD__) && defined(__GNUC__)) || (defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 3) && !defined(__SGI_STL_PORT))
#elif (defined(__sgi) && (!defined(__SGI_STL_PORT) || __SGI_STL_PORT < 0x400))\
|| (defined __APPLE__)\
|| (defined(__OpenBSD__) && defined(__GNUC__))\
|| (defined(__NetBSD__) && defined(__GNUC__))\
|| (defined(__FreeBSD__) && defined(__GNUC__))\
|| (defined(__DragonFly__) && defined(__GNUC__))\
|| (defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 3) && !defined(__SGI_STL_PORT))
// No WCHAR_MIN and WCHAR_MAX, wchar_t has the same range as int.
// - SGI MIPSpro with native library
// - gcc 3.x on HP-UX
// - Mac OS X with native library
// - gcc on FreeBSD
// - gcc on FreeBSD, OpenBSD and NetBSD
public detail::integer_traits_base<wchar_t, INT_MIN, INT_MAX>
#elif defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 2) && !defined(__SGI_STL_PORT)
// No WCHAR_MIN and WCHAR_MAX, wchar_t has the same range as unsigned int.
// - gcc 2.95.x on HP-UX
// (also, std::numeric_limits<wchar_t> appears to return the wrong values).
public detail::integer_traits_base<wchar_t, 0, UINT_MAX>
#else
#error No WCHAR_MIN and WCHAR_MAX present, please adjust integer_traits<> for your compiler.
#endif
@ -147,42 +161,96 @@ class integer_traits<unsigned long>
public detail::integer_traits_base<unsigned long, 0, ULONG_MAX>
{ };
#if defined(ULLONG_MAX) && !defined(__SUNPRO_CC)
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T)
#if defined(ULLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
template<>
class integer_traits<long long>
: public std::numeric_limits<long long>,
public detail::integer_traits_base<long long, LLONG_MIN, LLONG_MAX>
class integer_traits< ::boost::long_long_type>
: public std::numeric_limits< ::boost::long_long_type>,
public detail::integer_traits_base< ::boost::long_long_type, LLONG_MIN, LLONG_MAX>
{ };
template<>
class integer_traits<unsigned long long>
: public std::numeric_limits<unsigned long long>,
public detail::integer_traits_base<unsigned long long, 0, ULLONG_MAX>
class integer_traits< ::boost::ulong_long_type>
: public std::numeric_limits< ::boost::ulong_long_type>,
public detail::integer_traits_base< ::boost::ulong_long_type, 0, ULLONG_MAX>
{ };
#elif defined(ULONG_LONG_MAX)
#elif defined(ULONG_LONG_MAX) && defined(BOOST_HAS_LONG_LONG)
template<>
class integer_traits<long long>
: public std::numeric_limits<long long>,
public detail::integer_traits_base<long long, LONG_LONG_MIN, LONG_LONG_MAX>
{ };
class integer_traits< ::boost::long_long_type> : public std::numeric_limits< ::boost::long_long_type>, public detail::integer_traits_base< ::boost::long_long_type, LONG_LONG_MIN, LONG_LONG_MAX>{ };
template<>
class integer_traits<unsigned long long>
: public std::numeric_limits<unsigned long long>,
public detail::integer_traits_base<unsigned long long, 0, ULONG_LONG_MAX>
class integer_traits< ::boost::ulong_long_type>
: public std::numeric_limits< ::boost::ulong_long_type>,
public detail::integer_traits_base< ::boost::ulong_long_type, 0, ULONG_LONG_MAX>
{ };
#elif defined(ULONGLONG_MAX) && !defined(BOOST_MSVC) && !defined(__BORLANDC__)
#elif defined(ULONGLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
template<>
class integer_traits<long long>
: public std::numeric_limits<long long>,
public detail::integer_traits_base<long long, LONGLONG_MIN, LONGLONG_MAX>
class integer_traits< ::boost::long_long_type>
: public std::numeric_limits< ::boost::long_long_type>,
public detail::integer_traits_base< ::boost::long_long_type, LONGLONG_MIN, LONGLONG_MAX>
{ };
template<>
class integer_traits<unsigned long long>
: public std::numeric_limits<unsigned long long>,
public detail::integer_traits_base<unsigned long long, 0, ULONGLONG_MAX>
class integer_traits< ::boost::ulong_long_type>
: public std::numeric_limits< ::boost::ulong_long_type>,
public detail::integer_traits_base< ::boost::ulong_long_type, 0, ULONGLONG_MAX>
{ };
#elif defined(_LLONG_MAX) && defined(_C2) && defined(BOOST_HAS_LONG_LONG)
template<>
class integer_traits< ::boost::long_long_type>
: public std::numeric_limits< ::boost::long_long_type>,
public detail::integer_traits_base< ::boost::long_long_type, -_LLONG_MAX - _C2, _LLONG_MAX>
{ };
template<>
class integer_traits< ::boost::ulong_long_type>
: public std::numeric_limits< ::boost::ulong_long_type>,
public detail::integer_traits_base< ::boost::ulong_long_type, 0, _ULLONG_MAX>
{ };
#elif defined(BOOST_HAS_LONG_LONG)
//
// we have long long but no constants, this happens for example with gcc in -ansi mode,
// we'll just have to work out the values for ourselves (assumes 2's compliment representation):
//
template<>
class integer_traits< ::boost::long_long_type>
: public std::numeric_limits< ::boost::long_long_type>,
public detail::integer_traits_base< ::boost::long_long_type, (1LL << (sizeof(::boost::long_long_type) * CHAR_BIT - 1)), ~(1LL << (sizeof(::boost::long_long_type) * CHAR_BIT - 1))>
{ };
template<>
class integer_traits< ::boost::ulong_long_type>
: public std::numeric_limits< ::boost::ulong_long_type>,
public detail::integer_traits_base< ::boost::ulong_long_type, 0, ~0uLL>
{ };
#elif defined(BOOST_HAS_MS_INT64)
template<>
class integer_traits< __int64>
: public std::numeric_limits< __int64>,
public detail::integer_traits_base< __int64, _I64_MIN, _I64_MAX>
{ };
template<>
class integer_traits< unsigned __int64>
: public std::numeric_limits< unsigned __int64>,
public detail::integer_traits_base< unsigned __int64, 0, _UI64_MAX>
{ };
#endif
#endif
} // namespace boost
#endif /* BOOST_INTEGER_TRAITS_HPP */

View File

@ -0,0 +1,9 @@
#ifndef BOOST_PENDING_INTEGER_LOG2_HPP
#define BOOST_PENDING_INTEGER_LOG2_HPP
#include <boost/integer/integer_log2.hpp>
#include <boost/config/header_deprecated.hpp>
BOOST_HEADER_DEPRECATED("<boost/integer/integer_log2.hpp>");
#endif

128
index.htm
View File

@ -1,128 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Boost Integer Library</title>
</head>
<body bgcolor="white" text="black">
<table border="1" bgcolor="teal" cellpadding="2">
<tr>
<td bgcolor="white"><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86"></td>
<td><a href="../../index.htm"><font face="Arial" color="white"><big>Home</big></font></a></td>
<td><a href="../libraries.htm"><font face="Arial" color="white"><big>Libraries</big></font></a></td>
<td><a href="../../people/people.htm"><font face="Arial" color="white"><big>People</big></font></a></td>
<td><a href="../../more/faq.htm"><font face="Arial" color="white"><big>FAQ</big></font></a></td>
<td><a href="../../more/index.htm"><font face="Arial" color="white"><big>More</big></font></a></td>
</tr>
</table>
<h1>Boost Integer Library</h1>
<table border="1" cellpadding="5">
<tr>
<th>Header / Docs</th>
<th>Contents</th>
<th>Use</th>
</tr>
<tr>
<td align="center"><cite><a href="../../boost/integer_fwd.hpp">&lt;boost/integer_fwd.hpp&gt;</a></cite></td>
<td valign="top">Forward declarations of classes and class templates</td>
<td valign="top">When just the name of a class is needed</td>
</tr>
<tr>
<td align="center"><code><a href="../../boost/cstdint.hpp">&lt;boost/cstdint.hpp&gt;<br>
</a></code><a href="cstdint.htm"><br>
documentation</a>
</td>
<td valign="top">Typedef's based on the 1999 C Standard header &lt;<code>stdint.h&gt;</code>, wrapped in namespace boost.
This implementation may #include the compiler
supplied &lt;<code>stdint.h&gt;</code>, if present. </td>
<td valign="top">Supplies typedefs for standard integer types such as <code> int32_t</code> or <code>uint_least16_t</code>.
Use in preference to &lt;<code>stdint.h&gt;</code>
for enhanced portability. Furthermore, all names are safely placed in the boost namespace.</td>
</tr>
<tr>
<td align="center"><code><a href="../../boost/integer_traits.hpp">&lt;boost/integer_traits.hpp&gt;</a></code><br>
<br>
<a href="integer_traits.html">documentation</a>
</td>
<td valign="top">Template class <code>boost::integer_traits</code>, derived from <code>std::numeric_limits</code>.&nbsp;
Adds <code>const_min</code> and <code>const_max</code> members.</td>
<td valign="top">Use to obtain the characteristics of a known integer type.</td>
</tr>
<tr>
<td align="center"><code><a href="../../boost/integer.hpp">&lt;boost/integer.hpp&gt;</a><br>
<br>
</code><a href="integer.htm">documentation</a></td>
<td valign="top">Templates for integer type selection based on properties such as
maximum value or number of bits.</td>
<td valign="top">Use to select the type an integer when some property such as maximum value or number of bits is known.
Useful for generic programming. </td>
</tr>
<tr>
<td align="center"><code><a href="../../boost/integer/integer_mask.hpp">&lt;boost/integer/integer_mask.hpp&gt;</a><br>
<br>
</code><a href="doc/integer_mask.html">documentation</a></td>
<td valign="top">Templates for the selection of integer masks, single or lowest group, based on the number of bits.</td>
<td valign="top">Use to select a particular mask when the bit position(s) are based on a compile-time variable.
Useful for generic programming. </td>
</tr>
<tr>
<td align="center"><code><a href="../../boost/integer/static_log2.hpp">&lt;boost/integer/static_log2.hpp&gt;</a><br>
<br>
</code><a href="doc/static_log2.html">documentation</a></td>
<td valign="top">Template for finding the highest power of two in a number.</td>
<td valign="top">Use to find the bit-size/range based on a maximum value.
Useful for generic programming. </td>
</tr>
<tr>
<td align="center"><code><a href="../../boost/integer/static_min_max.hpp">&lt;boost/integer/static_min_max.hpp&gt;</a><br>
<br>
</code><a href="doc/static_min_max.html">documentation</a></td>
<td valign="top">Templates for finding the extrema of two numbers.</td>
<td valign="top">Use to find a bound based on a minimum or maximum value.
Useful for generic programming. </td>
</tr>
</table>
<h2>Rationale</h2>
<p>The organization of boost integer headers and classes is designed to
take advantage of <cite>&lt;stdint.h&gt;</cite> types from the 1999 C
standard without resorting to undefined behavior in terms of the 1998
C++ standard. The header <cite>&lt;boost/cstdint.hpp&gt;</cite> makes
the standard integer types safely available in namespace
<code>boost</code> without placing any names in namespace
<code>std</code>. As always, the intension is to complement rather than
compete with the C++ Standard Library. Should some future C++ standard
include <cite>&lt;stdint.h&gt;</cite> and <cite>&lt;cstdint&gt;</cite>,
then <cite>&lt;boost/cstdint.hpp&gt;</cite> will continue to function,
but will become redundant and may be safely deprecated.</p>
<p>Because these are boost headers, their names conform to boost header
naming conventions rather than C++ Standard Library header naming
conventions.</p>
<h2><i>Caveat emptor</i></h2>
<p>As an implementation artifact, certain C
<cite>&lt;limits.h&gt;</cite> macro names may possibly be visible to
users of <cite>&lt;boost/cstdint.hpp&gt;</cite>. Don't use these
macros; they are not part of any Boost-specified interface. Use
<code>boost::integer_traits&lt;&gt;</code> or
<code>std::numeric_limits&lt;&gt;</code> instead.</p>
<p>As another implementation artifact, certain C
<cite>&lt;stdint.h&gt;</cite> typedef names may possibly be visible in
the global namespace to users of <cite>&lt;boost/cstdint.hpp&gt;</cite>.
Don't use these names, they are not part of any Boost-specified
interface. Use the respective names in namespace <code>boost</code>
instead.</p>
<hr>
<p>Revised: <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %b %Y" startspan -->03 Oct 2001<!--webbot bot="Timestamp" endspan i-checksum="14373" -->
</p>
</body>
</html>

16
index.html Normal file
View File

@ -0,0 +1,16 @@
<html>
<head>
<meta http-equiv="refresh" content="0; URL=doc/html/index.html">
</head>
<body>
Automatic redirection failed, please go to
<a href="doc/html/index.html">doc/html/index.html</a>.
<P>Copyright Beman Dawes, Daryle Walker, Gennaro Prota and John Maddock 2001-2009</P>
<P>Distributed under the Boost Software License, Version 1.0. (See accompanying file <A href="../../LICENSE_1_0.txt">
LICENSE_1_0.txt</A> or copy at <A href="https://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</A>).</P>
</body>
</html>

View File

@ -1,213 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Integer Type Selection Templates</title>
</head>
<body bgcolor="white" text="black">
<h1>
<img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)"
align="middle" width="277" height="86">Integer Type Selection
Templates</h1>
<p>The <cite><a
href="../../boost/integer.hpp">&lt;boost/integer.hpp&gt;</a></cite> type
selection templates allow integer types to be selected based on desired
characteristics such as number of bits or maximum value. This facility
is particularly useful for solving generic programming problems.</p>
<h2><a name="contents">Contents</a></h2>
<ul>
<li><a href="#contents">Contents</a></li>
<li><a href="#synopsis">Synopsis</a></li>
<li><a href="#easy">Easiest-to-Manipulate Types</a></li>
<li><a href="#sized">Sized Types</a></li>
<li><a href="#example">Example</a></li>
<li><a href="#demo">Demonstration Program</a></li>
<li><a href="#rationale">Rationale</a></li>
<li><a href="#alternative">Alternative</a></li>
<li><a href="#credits">Credits</a></li>
</ul>
<h2><a name="synopsis">Synopsis</a></h2>
<blockquote><pre>namespace boost
{
// fast integers from least integers
template&lt; typename LeastInt &gt;
struct int_fast_t
{
typedef <em>implementation_supplied</em> fast;
};
// signed
template&lt; int Bits &gt;
struct int_t
{
typedef <em>implementation_supplied</em> least;
typedef int_fast_t&lt;least&gt;::fast fast;
};
// unsigned
template&lt; int Bits &gt;
struct uint_t
{
typedef <em>implementation_supplied</em> least;
typedef int_fast_t&lt;least&gt;::fast fast;
};
// signed
template&lt; long MaxValue &gt;
struct int_max_value_t
{
typedef <em>implementation_supplied</em> least;
typedef int_fast_t&lt;least&gt;::fast fast;
};
template&lt; long MinValue &gt;
struct int_min_value_t
{
typedef <em>implementation_supplied</em> least;
typedef int_fast_t&lt;least&gt;::fast fast;
};
// unsigned
template&lt; unsigned long Value &gt;
struct uint_value_t
{
typedef <em>implementation_supplied</em> least;
typedef int_fast_t&lt;least&gt;::fast fast;
};
} // namespace boost
</pre></blockquote>
<h2><a name="easy">Easiest-to-Manipulate Types</a></h2>
<p>The <code>int_fast_t</code> class template maps its input type to the
next-largest type that the processor can manipulate the easiest, or to
itself if the input type is already an easy-to-manipulate type. For
instance, processing a bunch of <code>char</code> objects may go faster
if they were converted to <code>int</code> objects before processing.
The input type, passed as the only template parameter, must be a
built-in integral type, except <code>bool</code>. Unsigned integral
types can be used, as well as signed integral types, despite the name.
The output type is given as the class member <code>fast</code>.</p>
<p><strong>Implementation Notes</strong><br>
By default, the output type is identical to the input type. Eventually,
this code's implementation should be conditionalized for each platform
to give accurate mappings between the built-in types and the
easiest-to-manipulate built-in types. Also, there is no guarantee that
the output type actually is easier to manipulate than the input
type.</p>
<h2><a name="sized">Sized Types</a></h2>
<p>The <code>int_t</code>, <code>uint_t</code>,
<code>int_max_value_t</code>, <code>int_min_value_t</code>, and
<code>uint_value_t</code> class templates find the most appropiate
built-in integral type for the given template parameter. This type is
given by the class member <code>least</code>. The easiest-to-manipulate
version of that type is given by the class member <code>fast</code>.
The following table describes each template's criteria.</p>
<table border="1" cellpadding="5">
<caption>Criteria for the Sized Type Class Templates</caption>
<tr>
<th>Class Template</th>
<th>Template Parameter Mapping</th>
</tr>
<tr>
<td><code>boost::int_t</code></td>
<td>The smallest built-in signed integral type with at least the
given number of bits, including the sign bit. The parameter
should be a positive number. A compile-time error results if
the parameter is larger than the number of bits in a
<code>long</code>.</td>
</tr>
<tr>
<td><code>boost::uint_t</code></td>
<td>The smallest built-in unsigned integral type with at least
the given number of bits. The parameter should be a positive
number. A compile-time error results if the parameter is
larger than the number of bits in an <code>unsigned
long</code>.</td>
</tr>
<tr>
<td><code>boost::int_max_value_t</code></td>
<td>The smallest built-in signed integral type that supports the
given value as a maximum. The parameter should be a
positive number.</td>
</tr>
<tr>
<td><code>boost::int_min_value_t</code></td>
<td>The smallest built-in signed integral type that supports the
given value as a minimum. The parameter should be a
negative number.</td>
</tr>
<tr>
<td><code>boost::uint_value_t</code></td>
<td>The smallest built-in unsigned integral type that supports
the given value as a maximum. The parameter should be a
positive number.</td>
</tr>
</table>
<h2><a name="example">Example</a></h2>
<blockquote><pre>#include &lt;boost/integer.hpp&gt;
//...
int main()
{
boost::int_t&lt;24&gt;::least my_var;
//...
}
</pre></blockquote>
<h2><a name="demo">Demonstration Program</a></h2>
<p>The program <a href="integer_test.cpp">integer_test.cpp</a> is a
simplistic demonstration of the results from instantiating various
examples of the sized type class templates.</p>
<h2><a name="rationale">Rationale</a></h2>
<p>The rationale for the design of the templates in this header includes:</p>
<ul>
<li>Avoid recursion because of concern about C++'s limited
guaranteed recursion depth (17).</li>
<li>Avoid macros on general principles.</li>
<li>Try to keep the design as simple as possible.</li>
</ul>
<h2><a name="alternative">Alternative</a></h2>
<p>If the number of bits required is known beforehand, it may be more
appropriate to use the types supplied in <cite><a
href="../../boost/cstdint.hpp">&lt;boost/cstdint.hpp&gt;</a></cite>.</p>
<h2><a name="credits">Credits</a></h2>
<p>The author of most of the Boost integer type choosing templates is <a
href="../../people/beman_dawes.html">Beman Dawes</a>. He gives thanks
to Valentin Bonnard and
<a href="../../people/kevlin_henney.htm"> Kevlin Henney</a> for sharing
their designs for similar templates. <a
href="../../people/daryle_walker.html">Daryle Walker</a> designed the
value-based sized templates.</p>
<hr>
<p>Revised May 20, 2001</p>
<p>&copy; Copyright Beman Dawes 1999. Permission to copy, use, modify,
sell and distribute this document is granted provided this copyright
notice appears in all copies. This document is provided &quot;as
is&quot; without express or implied warranty, and with no claim as to
its suitability for any purpose.</p>
</body>
</html>

View File

@ -1,255 +0,0 @@
// boost integer.hpp test program ------------------------------------------//
// (C) Copyright Beman Dawes 1999. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 04 Oct 01 Added tests for new templates; rewrote code (Daryle Walker)
// 10 Mar 01 Boost Test Library now used for tests (Beman Dawes)
// 31 Aug 99 Initial version
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp> // for main, BOOST_TEST
#include <boost/config.hpp> // for BOOST_NO_USING_TEMPLATE
#include <boost/cstdlib.hpp> // for boost::exit_success
#include <boost/integer.hpp> // for boost::int_t, boost::uint_t
#include <climits> // for ULONG_MAX, LONG_MAX, LONG_MIN
#include <iostream> // for std::cout (std::endl indirectly)
#include <typeinfo> // for std::type_info
// Control if the names of the types for each version
// of the integer templates will be printed.
#ifndef CONTROL_SHOW_TYPES
#define CONTROL_SHOW_TYPES 0
#endif
// If specializations have not already been done, then we can confirm
// the effects of the "fast" types by making a specialization.
namespace boost
{
template < >
struct int_fast_t< short >
{
typedef long fast;
};
}
// Show the types of an integer template version
#if CONTROL_SHOW_TYPES
#define SHOW_TYPE(Template, Number, Type) ::std::cout << "Type \"" \
#Template "<" #Number ">::" #Type "\" is \"" << typeid(Template < \
Number > :: Type).name() << ".\"\n"
#else
#define SHOW_TYPE(Template, Number, Type)
#endif
#define SHOW_TYPES(Template, Type) SHOW_TYPE(Template, 32, Type); \
SHOW_TYPE(Template, 31, Type); SHOW_TYPE(Template, 30, Type); \
SHOW_TYPE(Template, 29, Type); SHOW_TYPE(Template, 28, Type); \
SHOW_TYPE(Template, 27, Type); SHOW_TYPE(Template, 26, Type); \
SHOW_TYPE(Template, 25, Type); SHOW_TYPE(Template, 24, Type); \
SHOW_TYPE(Template, 23, Type); SHOW_TYPE(Template, 22, Type); \
SHOW_TYPE(Template, 21, Type); SHOW_TYPE(Template, 20, Type); \
SHOW_TYPE(Template, 19, Type); SHOW_TYPE(Template, 18, Type); \
SHOW_TYPE(Template, 17, Type); SHOW_TYPE(Template, 16, Type); \
SHOW_TYPE(Template, 15, Type); SHOW_TYPE(Template, 14, Type); \
SHOW_TYPE(Template, 13, Type); SHOW_TYPE(Template, 12, Type); \
SHOW_TYPE(Template, 11, Type); SHOW_TYPE(Template, 10, Type); \
SHOW_TYPE(Template, 9, Type); SHOW_TYPE(Template, 8, Type); \
SHOW_TYPE(Template, 7, Type); SHOW_TYPE(Template, 6, Type); \
SHOW_TYPE(Template, 5, Type); SHOW_TYPE(Template, 4, Type); \
SHOW_TYPE(Template, 3, Type); SHOW_TYPE(Template, 2, Type); \
SHOW_TYPE(Template, 1, Type); SHOW_TYPE(Template, 0, Type)
#define SHOW_SHIFTED_TYPE(Template, Number, Type) SHOW_TYPE(Template, (1UL << Number), Type)
#define SHOW_SHIFTED_TYPES(Template, Type) SHOW_SHIFTED_TYPE(Template, 30, Type); \
SHOW_SHIFTED_TYPE(Template, 29, Type); SHOW_SHIFTED_TYPE(Template, 28, Type); \
SHOW_SHIFTED_TYPE(Template, 27, Type); SHOW_SHIFTED_TYPE(Template, 26, Type); \
SHOW_SHIFTED_TYPE(Template, 25, Type); SHOW_SHIFTED_TYPE(Template, 24, Type); \
SHOW_SHIFTED_TYPE(Template, 23, Type); SHOW_SHIFTED_TYPE(Template, 22, Type); \
SHOW_SHIFTED_TYPE(Template, 21, Type); SHOW_SHIFTED_TYPE(Template, 20, Type); \
SHOW_SHIFTED_TYPE(Template, 19, Type); SHOW_SHIFTED_TYPE(Template, 18, Type); \
SHOW_SHIFTED_TYPE(Template, 17, Type); SHOW_SHIFTED_TYPE(Template, 16, Type); \
SHOW_SHIFTED_TYPE(Template, 15, Type); SHOW_SHIFTED_TYPE(Template, 14, Type); \
SHOW_SHIFTED_TYPE(Template, 13, Type); SHOW_SHIFTED_TYPE(Template, 12, Type); \
SHOW_SHIFTED_TYPE(Template, 11, Type); SHOW_SHIFTED_TYPE(Template, 10, Type); \
SHOW_SHIFTED_TYPE(Template, 9, Type); SHOW_SHIFTED_TYPE(Template, 8, Type); \
SHOW_SHIFTED_TYPE(Template, 7, Type); SHOW_SHIFTED_TYPE(Template, 6, Type); \
SHOW_SHIFTED_TYPE(Template, 5, Type); SHOW_SHIFTED_TYPE(Template, 4, Type); \
SHOW_SHIFTED_TYPE(Template, 3, Type); SHOW_SHIFTED_TYPE(Template, 2, Type); \
SHOW_SHIFTED_TYPE(Template, 1, Type); SHOW_SHIFTED_TYPE(Template, 0, Type)
#define SHOW_POS_SHIFTED_TYPE(Template, Number, Type) SHOW_TYPE(Template, +(1L << Number), Type)
#define SHOW_POS_SHIFTED_TYPES(Template, Type) SHOW_POS_SHIFTED_TYPE(Template, 30, Type); \
SHOW_POS_SHIFTED_TYPE(Template, 29, Type); SHOW_POS_SHIFTED_TYPE(Template, 28, Type); \
SHOW_POS_SHIFTED_TYPE(Template, 27, Type); SHOW_POS_SHIFTED_TYPE(Template, 26, Type); \
SHOW_POS_SHIFTED_TYPE(Template, 25, Type); SHOW_POS_SHIFTED_TYPE(Template, 24, Type); \
SHOW_POS_SHIFTED_TYPE(Template, 23, Type); SHOW_POS_SHIFTED_TYPE(Template, 22, Type); \
SHOW_POS_SHIFTED_TYPE(Template, 21, Type); SHOW_POS_SHIFTED_TYPE(Template, 20, Type); \
SHOW_POS_SHIFTED_TYPE(Template, 19, Type); SHOW_POS_SHIFTED_TYPE(Template, 18, Type); \
SHOW_POS_SHIFTED_TYPE(Template, 17, Type); SHOW_POS_SHIFTED_TYPE(Template, 16, Type); \
SHOW_POS_SHIFTED_TYPE(Template, 15, Type); SHOW_POS_SHIFTED_TYPE(Template, 14, Type); \
SHOW_POS_SHIFTED_TYPE(Template, 13, Type); SHOW_POS_SHIFTED_TYPE(Template, 12, Type); \
SHOW_POS_SHIFTED_TYPE(Template, 11, Type); SHOW_POS_SHIFTED_TYPE(Template, 10, Type); \
SHOW_POS_SHIFTED_TYPE(Template, 9, Type); SHOW_POS_SHIFTED_TYPE(Template, 8, Type); \
SHOW_POS_SHIFTED_TYPE(Template, 7, Type); SHOW_POS_SHIFTED_TYPE(Template, 6, Type); \
SHOW_POS_SHIFTED_TYPE(Template, 5, Type); SHOW_POS_SHIFTED_TYPE(Template, 4, Type); \
SHOW_POS_SHIFTED_TYPE(Template, 3, Type); SHOW_POS_SHIFTED_TYPE(Template, 2, Type); \
SHOW_POS_SHIFTED_TYPE(Template, 1, Type); SHOW_POS_SHIFTED_TYPE(Template, 0, Type)
#define SHOW_NEG_SHIFTED_TYPE(Template, Number, Type) SHOW_TYPE(Template, -(1L << Number), Type)
#define SHOW_NEG_SHIFTED_TYPES(Template, Type) SHOW_NEG_SHIFTED_TYPE(Template, 30, Type); \
SHOW_NEG_SHIFTED_TYPE(Template, 29, Type); SHOW_NEG_SHIFTED_TYPE(Template, 28, Type); \
SHOW_NEG_SHIFTED_TYPE(Template, 27, Type); SHOW_NEG_SHIFTED_TYPE(Template, 26, Type); \
SHOW_NEG_SHIFTED_TYPE(Template, 25, Type); SHOW_NEG_SHIFTED_TYPE(Template, 24, Type); \
SHOW_NEG_SHIFTED_TYPE(Template, 23, Type); SHOW_NEG_SHIFTED_TYPE(Template, 22, Type); \
SHOW_NEG_SHIFTED_TYPE(Template, 21, Type); SHOW_NEG_SHIFTED_TYPE(Template, 20, Type); \
SHOW_NEG_SHIFTED_TYPE(Template, 19, Type); SHOW_NEG_SHIFTED_TYPE(Template, 18, Type); \
SHOW_NEG_SHIFTED_TYPE(Template, 17, Type); SHOW_NEG_SHIFTED_TYPE(Template, 16, Type); \
SHOW_NEG_SHIFTED_TYPE(Template, 15, Type); SHOW_NEG_SHIFTED_TYPE(Template, 14, Type); \
SHOW_NEG_SHIFTED_TYPE(Template, 13, Type); SHOW_NEG_SHIFTED_TYPE(Template, 12, Type); \
SHOW_NEG_SHIFTED_TYPE(Template, 11, Type); SHOW_NEG_SHIFTED_TYPE(Template, 10, Type); \
SHOW_NEG_SHIFTED_TYPE(Template, 9, Type); SHOW_NEG_SHIFTED_TYPE(Template, 8, Type); \
SHOW_NEG_SHIFTED_TYPE(Template, 7, Type); SHOW_NEG_SHIFTED_TYPE(Template, 6, Type); \
SHOW_NEG_SHIFTED_TYPE(Template, 5, Type); SHOW_NEG_SHIFTED_TYPE(Template, 4, Type); \
SHOW_NEG_SHIFTED_TYPE(Template, 3, Type); SHOW_NEG_SHIFTED_TYPE(Template, 2, Type); \
SHOW_NEG_SHIFTED_TYPE(Template, 1, Type); SHOW_NEG_SHIFTED_TYPE(Template, 0, Type)
// Test if a constant can fit within a certain type
#define PRIVATE_FIT_TEST(Template, Number, Type, Value) BOOST_TEST( Template < Number > :: Type ( Value ) == Value )
#define PRIVATE_FIT_TESTS(Template, Type, ValType, InitVal) do { ValType v = InitVal ; PRIVATE_FIT_TEST(Template, 32, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 31, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 30, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 29, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 28, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 27, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 26, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 25, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 24, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 23, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 22, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 21, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 20, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 19, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 18, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 17, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 16, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 15, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 14, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 13, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 12, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 11, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 10, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 9, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 8, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 7, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 6, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 5, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 4, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 3, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 2, Type, v); v >>= 1; \
PRIVATE_FIT_TEST(Template, 1, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 0, Type, v); } while ( false )
#define PRIVATE_SHIFTED_FIT_TEST(Template, Number, Type, Value) BOOST_TEST( Template < (ULONG_MAX >> Number) > :: Type ( Value ) == Value )
#define PRIVATE_SHIFTED_FIT_TESTS(Template, Type, ValType, InitVal) do { ValType v = InitVal ; \
PRIVATE_SHIFTED_FIT_TEST(Template, 0, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 1, Type, v); v >>= 1; \
PRIVATE_SHIFTED_FIT_TEST(Template, 2, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 3, Type, v); v >>= 1; \
PRIVATE_SHIFTED_FIT_TEST(Template, 4, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 5, Type, v); v >>= 1; \
PRIVATE_SHIFTED_FIT_TEST(Template, 6, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 7, Type, v); v >>= 1; \
PRIVATE_SHIFTED_FIT_TEST(Template, 8, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 9, Type, v); v >>= 1; \
PRIVATE_SHIFTED_FIT_TEST(Template, 10, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 11, Type, v); v >>= 1; \
PRIVATE_SHIFTED_FIT_TEST(Template, 12, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 13, Type, v); v >>= 1; \
PRIVATE_SHIFTED_FIT_TEST(Template, 14, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 15, Type, v); v >>= 1; \
PRIVATE_SHIFTED_FIT_TEST(Template, 16, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 17, Type, v); v >>= 1; \
PRIVATE_SHIFTED_FIT_TEST(Template, 18, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 19, Type, v); v >>= 1; \
PRIVATE_SHIFTED_FIT_TEST(Template, 20, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 21, Type, v); v >>= 1; \
PRIVATE_SHIFTED_FIT_TEST(Template, 22, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 23, Type, v); v >>= 1; \
PRIVATE_SHIFTED_FIT_TEST(Template, 24, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 25, Type, v); v >>= 1; \
PRIVATE_SHIFTED_FIT_TEST(Template, 26, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 27, Type, v); v >>= 1; \
PRIVATE_SHIFTED_FIT_TEST(Template, 28, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 29, Type, v); v >>= 1; \
PRIVATE_SHIFTED_FIT_TEST(Template, 30, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 31, Type, v); } while ( false )
#define PRIVATE_POS_SHIFTED_FIT_TEST(Template, Number, Type, Value) BOOST_TEST( Template < (LONG_MAX >> Number) > :: Type ( Value ) == Value )
#define PRIVATE_POS_FIT_TESTS(Template, Type, ValType, InitVal) do { ValType v = InitVal ; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 0, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 1, Type, v); v >>= 1; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 2, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 3, Type, v); v >>= 1; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 4, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 5, Type, v); v >>= 1; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 6, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 7, Type, v); v >>= 1; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 8, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 9, Type, v); v >>= 1; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 10, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 11, Type, v); v >>= 1; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 12, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 13, Type, v); v >>= 1; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 14, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 15, Type, v); v >>= 1; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 16, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 17, Type, v); v >>= 1; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 18, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 19, Type, v); v >>= 1; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 20, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 21, Type, v); v >>= 1; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 22, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 23, Type, v); v >>= 1; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 24, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 25, Type, v); v >>= 1; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 26, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 27, Type, v); v >>= 1; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 28, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 29, Type, v); v >>= 1; \
PRIVATE_POS_SHIFTED_FIT_TEST(Template, 30, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 31, Type, v); } while ( false )
#define PRIVATE_NEG_SHIFTED_FIT_TEST(Template, Number, Type, Value) BOOST_TEST( Template < (LONG_MIN >> Number) > :: Type ( Value ) == Value )
#define PRIVATE_NEG_FIT_TESTS(Template, Type, ValType, InitVal) do { ValType v = InitVal ; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 0, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 1, Type, v); v >>= 1; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 2, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 3, Type, v); v >>= 1; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 4, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 5, Type, v); v >>= 1; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 6, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 7, Type, v); v >>= 1; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 8, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 9, Type, v); v >>= 1; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 10, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 11, Type, v); v >>= 1; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 12, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 13, Type, v); v >>= 1; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 14, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 15, Type, v); v >>= 1; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 16, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 17, Type, v); v >>= 1; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 18, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 19, Type, v); v >>= 1; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 20, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 21, Type, v); v >>= 1; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 22, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 23, Type, v); v >>= 1; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 24, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 25, Type, v); v >>= 1; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 26, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 27, Type, v); v >>= 1; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 28, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 29, Type, v); v >>= 1; \
PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 30, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 31, Type, v); } while ( false )
// Test program
int
test_main
(
int,
char*[]
)
{
#ifndef BOOST_NO_USING_TEMPLATE
using boost::int_t;
using boost::uint_t;
using boost::int_max_value_t;
using boost::int_min_value_t;
using boost::uint_value_t;
#else
using namespace boost;
#endif
SHOW_TYPES( int_t, least );
SHOW_TYPES( int_t, fast );
SHOW_TYPES( uint_t, least );
SHOW_TYPES( uint_t, fast );
SHOW_POS_SHIFTED_TYPES( int_max_value_t, least );
SHOW_POS_SHIFTED_TYPES( int_max_value_t, fast );
SHOW_NEG_SHIFTED_TYPES( int_min_value_t, least );
SHOW_NEG_SHIFTED_TYPES( int_min_value_t, fast );
SHOW_SHIFTED_TYPES( uint_value_t, least );
SHOW_SHIFTED_TYPES( uint_value_t, fast );
PRIVATE_FIT_TESTS( int_t, least, long, LONG_MAX );
PRIVATE_FIT_TESTS( int_t, fast, long, LONG_MAX );
PRIVATE_FIT_TESTS( uint_t, least, unsigned long, ULONG_MAX );
PRIVATE_FIT_TESTS( uint_t, fast, unsigned long, ULONG_MAX );
PRIVATE_POS_FIT_TESTS( int_max_value_t, least, long, LONG_MAX );
PRIVATE_POS_FIT_TESTS( int_max_value_t, fast, long, LONG_MAX );
PRIVATE_NEG_FIT_TESTS( int_min_value_t, least, long, LONG_MIN );
PRIVATE_NEG_FIT_TESTS( int_min_value_t, fast, long, LONG_MIN );
PRIVATE_SHIFTED_FIT_TESTS( uint_value_t, least, unsigned long, ULONG_MAX );
PRIVATE_SHIFTED_FIT_TESTS( uint_value_t, fast, unsigned long, ULONG_MAX );
return boost::exit_success;
}

View File

@ -1,89 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>integer_traits: Compile-Time Limits for Integral Types</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" align="center" width="277" height="86">Compile-Time Integral
Type Limits</h1>
<p>
The C++ Standard Library &lt;limits&gt; header supplies a class template
numeric_limits&lt;&gt; with specializations for each fundamental
type.</p>
<p>
For integer types, the interesting members of std::numeric_limits&lt;&gt; are:
<pre> static const bool is_specialized; // will be true for integers
static T min() throw();
static T max() throw();
static const int digits; // for integers, # value bits
static const int digits10;
static const bool is_signed;
static const bool is_integer; // will be true for integers</pre>
For many uses, these are sufficient. But min() and max() are problematical because they are not constant expressions
(std::5.19), yet some usages require constant expressions.
<p>
The template class <code>integer_traits</code> addresses this
problem.
<h2>Header <code><a href="../../boost/integer_traits.hpp">integer_traits.hpp</a></code> Synopsis</h2>
<pre>namespace boost {
template&lt;class T&gt;
class integer_traits : public std::numeric_limits&lt;T&gt;
{
static const bool is_integral = false;
};
// specializations for all integral types
}</pre>
<h2>Description</h2>
Template class <code>integer_traits</code> is derived from
<code>std::numeric_limits</code>. In general, it adds the single
<code>bool</code> member <code>is_integral</code> with the
compile-time constant value <code>false</code>. However, for all
integral types <code>T</code> (std::3.9.1/7 [basic.fundamental]),
there are specializations provided with the following compile-time
constants defined:
<p>
<table border=1>
<tr><th>member</th><th>type</th><th>value</th></tr>
<tr><td><code>is_integral</code></td><td>bool</td><td><code>true</code></td></tr>
<tr><td><code>const_min</code></td><td><code>T</code></td><td>equivalent
to <code>std::numeric_limits&lt;T&gt;::min()</code></td></tr>
<tr><td><code>const_max</code></td><td><code>T</code></td><td>equivalent
to <code>std::numeric_limits&lt;T&gt;::max()</code></td></tr>
</table>
<p>
<em>Note:</em> A flag <code>is_integral</code> is provided, because a
user-defined integer class should specialize
<code>std::numeric_limits&lt;&gt;::is_integer = true</code>,
nonetheless compile-time constants <code>const_min</code> and
<code>const_max</code> cannot be provided for that user-defined class.
<h2>
Test Program</h2>
<p>
The program <code><a href="integer_traits_test.cpp">integer_traits_test.cpp</a></code>
exercises the <code>integer_traits</code> class.
<h2>Acknowledgements</h2>
Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers discussed the integer
traits idea on the boost mailing list in August 1999.
<hr>
<a href="../../people/jens_maurer.htm">
Jens Maurer</a>, 2000-02-20

14
meta/libraries.json Normal file
View File

@ -0,0 +1,14 @@
{
"key": "integer",
"name": "Integer",
"description": "The organization of boost integer headers and classes is designed to take advantage of <stdint.h> types from the 1999 C standard without resorting to undefined behavior in terms of the 1998 C++ standard. The header <boost/cstdint.hpp> makes the standard integer types safely available in namespace boost without placing any names in namespace std.",
"category": [
"Math"
],
"authors": "",
"maintainers": [
"Daryle Walker <darylew -at- hotmail.com>",
"Andrey Semashev <andrey.semashev -at- gmail.com>"
],
"cxxstd": "03"
}

39
test/Jamfile.v2 Normal file
View File

@ -0,0 +1,39 @@
#~ Copyright Rene Rivera 2008
#~ Distributed under the Boost Software License, Version 1.0.
#~ (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
import testing ;
import ../../config/checks/config : requires ;
project : requirements <warnings>all <toolset>gcc:<cxxflags>-Wextra ;
obj has_gmpxx : has_gmpxx.cpp ;
explicit has_gmpxx ;
test-suite integer
:
[ run integer_traits_test.cpp ]
[ run integer_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-long-long <toolset>darwin:<cxxflags>-Wno-long-long <toolset>sun:<cxxflags>"-Qoption ccfe -tmpldepth=128" ]
[ run integer_mask_test.cpp ]
[ run integer_log2_test.cpp ]
[ run static_log2_test.cpp ]
[ run static_min_max_test.cpp ]
[ run extended_euclidean_test.cpp ]
[ run mod_inverse_test.cpp ]
[ compile integer_traits_include_test.cpp ]
[ compile integer_include_test.cpp ]
[ compile integer_mask_include_test.cpp ]
[ compile static_log2_include_test.cpp ]
[ compile static_min_max_include_test.cpp ]
[ compile integer_fwd_include_test.cpp ]
[ compile gcd_constexpr14_test.cpp ]
[ compile gcd_noexcept_test.cpp ]
[ compile-fail fail_int_exact.cpp ]
[ compile-fail fail_int_fast.cpp ]
[ compile-fail fail_int_least.cpp ]
[ compile-fail fail_uint_exact.cpp ]
[ compile-fail fail_uint_fast.cpp ]
[ compile-fail fail_uint_least.cpp ]
[ compile-fail fail_uint_65.cpp ]
[ run common_factor_test.cpp : : : [ check-target-builds has_gmpxx "Checking for gmpxx.h" : <define>BOOST_INTEGER_HAS_GMPXX_H=1 <linkflags>-lgmp <linkflags>-lgmpxx ] ]
;

653
test/common_factor_test.cpp Normal file
View File

@ -0,0 +1,653 @@
// Boost GCD & LCM common_factor.hpp test program --------------------------//
// (C) Copyright Daryle Walker 2001, 2006.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org for most recent version including documentation.
// Revision History
// 01 Dec 2006 Various fixes for old compilers (Joaquin M Lopez Munoz)
// 10 Nov 2006 Make long long and __int64 mutually exclusive (Daryle Walker)
// 04 Nov 2006 Use more built-in numeric types, binary-GCD (Daryle Walker)
// 03 Nov 2006 Use custom numeric types (Daryle Walker)
// 02 Nov 2006 Change to Boost.Test's unit test system (Daryle Walker)
// 07 Nov 2001 Initial version (Daryle Walker)
#define BOOST_TEST_MAIN "Boost.integer GCD & LCM unit tests"
#include <boost/config.hpp> // for BOOST_MSVC, etc.
#include <boost/detail/workaround.hpp>
#include <boost/integer/common_factor.hpp> // for boost::integer::gcd, etc.
#include <boost/mpl/list.hpp> // for boost::mpl::list
#include <boost/operators.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/rational.hpp>
#include <istream> // for std::basic_istream
#include <limits> // for std::numeric_limits
#include <ostream> // for std::basic_ostream
#ifdef BOOST_INTEGER_HAS_GMPXX_H
#include <gmpxx.h>
#endif
#include "multiprecision_config.hpp"
#ifndef DISABLE_MP_TESTS
#include <boost/multiprecision/cpp_int.hpp>
#endif
namespace {
// TODO: add polynominal/non-real type; especially after any switch to the
// binary-GCD algorithm for built-in types
// Custom integer class (template)
template < typename IntType, int ID = 0 >
class my_wrapped_integer
: private ::boost::shiftable1<my_wrapped_integer<IntType, ID>,
::boost::operators<my_wrapped_integer<IntType, ID> > >
{
// Helper type-aliases
typedef my_wrapped_integer self_type;
typedef IntType self_type::* bool_type;
// Member data
IntType v_;
public:
// Template parameters
typedef IntType int_type;
BOOST_STATIC_CONSTANT(int,id = ID);
// Lifetime management (use automatic destructor and copy constructor)
my_wrapped_integer( int_type const &v = int_type() ) : v_( v ) {}
// Accessors
int_type value() const { return this->v_; }
// Operators (use automatic copy assignment)
operator bool_type() const { return this->v_ ? &self_type::v_ : 0; }
self_type & operator ++() { ++this->v_; return *this; }
self_type & operator --() { --this->v_; return *this; }
self_type operator ~() const { return self_type( ~this->v_ ); }
self_type operator !() const { return self_type( !this->v_ ); }
self_type operator +() const { return self_type( +this->v_ ); }
self_type operator -() const { return self_type( -this->v_ ); }
bool operator <( self_type const &r ) const { return this->v_ < r.v_; }
bool operator ==( self_type const &r ) const { return this->v_ == r.v_; }
self_type &operator *=(self_type const &r) {this->v_ *= r.v_; return *this;}
self_type &operator /=(self_type const &r) {this->v_ /= r.v_; return *this;}
self_type &operator %=(self_type const &r) {this->v_ %= r.v_; return *this;}
self_type &operator +=(self_type const &r) {this->v_ += r.v_; return *this;}
self_type &operator -=(self_type const &r) {this->v_ -= r.v_; return *this;}
self_type &operator<<=(self_type const &r){this->v_ <<= r.v_; return *this;}
self_type &operator>>=(self_type const &r){this->v_ >>= r.v_; return *this;}
self_type &operator &=(self_type const &r) {this->v_ &= r.v_; return *this;}
self_type &operator |=(self_type const &r) {this->v_ |= r.v_; return *this;}
self_type &operator ^=(self_type const &r) {this->v_ ^= r.v_; return *this;}
// Input & output
friend std::istream & operator >>( std::istream &i, self_type &x )
{ return i >> x.v_; }
friend std::ostream & operator <<( std::ostream &o, self_type const &x )
{ return o << x.v_; }
}; // my_wrapped_integer
template < typename IntType, int ID >
my_wrapped_integer<IntType, ID> abs( my_wrapped_integer<IntType, ID> const &x )
{ return ( x < my_wrapped_integer<IntType, ID>(0) ) ? -x : +x; }
typedef my_wrapped_integer<int> MyInt1;
typedef my_wrapped_integer<unsigned> MyUnsigned1;
typedef my_wrapped_integer<int, 1> MyInt2;
typedef my_wrapped_integer<unsigned, 1> MyUnsigned2;
// Without these explicit instantiations, MSVC++ 6.5/7.0 does not find
// some friend operators in certain contexts.
MyInt1 dummy1;
MyUnsigned1 dummy2;
MyInt2 dummy3;
MyUnsigned2 dummy4;
// Various types to test with each GCD/LCM
typedef ::boost::mpl::list<signed char, short, int, long,
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1500)
#elif defined(BOOST_HAS_LONG_LONG)
boost::long_long_type,
#elif defined(BOOST_HAS_MS_INT64)
__int64,
#endif
MyInt1
#ifndef DISABLE_MP_TESTS
, boost::multiprecision::cpp_int
#endif
> signed_test_types;
typedef ::boost::mpl::list<unsigned char, unsigned short, unsigned,
unsigned long,
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1500)
#elif defined(BOOST_HAS_LONG_LONG)
boost::ulong_long_type,
#elif defined(BOOST_HAS_MS_INT64)
unsigned __int64,
#endif
MyUnsigned1, MyUnsigned2 /*, boost::multiprecision::uint256_t*/> unsigned_test_types;
} // namespace
#define BOOST_NO_MACRO_EXPAND /**/
// Specialize numeric_limits for _some_ of our types
namespace std
{
template < >
class numeric_limits< MyInt1 >
{
typedef MyInt1::int_type int_type;
typedef numeric_limits<int_type> limits_type;
public:
BOOST_STATIC_CONSTANT(bool, is_specialized = limits_type::is_specialized);
static MyInt1 min BOOST_NO_MACRO_EXPAND() throw() { return (limits_type::min)(); }
static MyInt1 max BOOST_NO_MACRO_EXPAND() throw() { return (limits_type::max)(); }
BOOST_STATIC_CONSTANT(int, digits = limits_type::digits);
BOOST_STATIC_CONSTANT(int, digits10 = limits_type::digits10);
#ifndef BOOST_NO_CXX11_NUMERIC_LIMITS
BOOST_STATIC_CONSTANT(int, max_digits10 = limits_type::max_digits10);
#endif
BOOST_STATIC_CONSTANT(bool, is_signed = limits_type::is_signed);
BOOST_STATIC_CONSTANT(bool, is_integer = limits_type::is_integer);
BOOST_STATIC_CONSTANT(bool, is_exact = limits_type::is_exact);
BOOST_STATIC_CONSTANT(int, radix = limits_type::radix);
static MyInt1 epsilon() throw() { return limits_type::epsilon(); }
static MyInt1 round_error() throw() { return limits_type::round_error(); }
BOOST_STATIC_CONSTANT(int, min_exponent = limits_type::min_exponent);
BOOST_STATIC_CONSTANT(int, min_exponent10 = limits_type::min_exponent10);
BOOST_STATIC_CONSTANT(int, max_exponent = limits_type::max_exponent);
BOOST_STATIC_CONSTANT(int, max_exponent10 = limits_type::max_exponent10);
BOOST_STATIC_CONSTANT(bool, has_infinity = limits_type::has_infinity);
BOOST_STATIC_CONSTANT(bool, has_quiet_NaN = limits_type::has_quiet_NaN);
BOOST_STATIC_CONSTANT(bool, has_signaling_NaN = limits_type::has_signaling_NaN);
BOOST_STATIC_CONSTANT(float_denorm_style, has_denorm = limits_type::has_denorm);
BOOST_STATIC_CONSTANT(bool, has_denorm_loss = limits_type::has_denorm_loss);
static MyInt1 infinity() throw() { return limits_type::infinity(); }
static MyInt1 quiet_NaN() throw() { return limits_type::quiet_NaN(); }
static MyInt1 signaling_NaN() throw() {return limits_type::signaling_NaN();}
static MyInt1 denorm_min() throw() { return limits_type::denorm_min(); }
BOOST_STATIC_CONSTANT(bool, is_iec559 = limits_type::is_iec559);
BOOST_STATIC_CONSTANT(bool, is_bounded = limits_type::is_bounded);
BOOST_STATIC_CONSTANT(bool, is_modulo = limits_type::is_modulo);
BOOST_STATIC_CONSTANT(bool, traps = limits_type::traps);
BOOST_STATIC_CONSTANT(bool, tinyness_before = limits_type::tinyness_before);
BOOST_STATIC_CONSTANT(float_round_style, round_style = limits_type::round_style);
}; // std::numeric_limits<MyInt1>
template < >
class numeric_limits< MyUnsigned1 >
{
typedef MyUnsigned1::int_type int_type;
typedef numeric_limits<int_type> limits_type;
public:
BOOST_STATIC_CONSTANT(bool, is_specialized = limits_type::is_specialized);
static MyUnsigned1 min BOOST_NO_MACRO_EXPAND() throw() { return (limits_type::min)(); }
static MyUnsigned1 max BOOST_NO_MACRO_EXPAND() throw() { return (limits_type::max)(); }
BOOST_STATIC_CONSTANT(int, digits = limits_type::digits);
BOOST_STATIC_CONSTANT(int, digits10 = limits_type::digits10);
#ifndef BOOST_NO_CXX11_NUMERIC_LIMITS
BOOST_STATIC_CONSTANT(int, max_digits10 = limits_type::max_digits10);
#endif
BOOST_STATIC_CONSTANT(bool, is_signed = limits_type::is_signed);
BOOST_STATIC_CONSTANT(bool, is_integer = limits_type::is_integer);
BOOST_STATIC_CONSTANT(bool, is_exact = limits_type::is_exact);
BOOST_STATIC_CONSTANT(int, radix = limits_type::radix);
static MyUnsigned1 epsilon() throw() { return limits_type::epsilon(); }
static MyUnsigned1 round_error() throw(){return limits_type::round_error();}
BOOST_STATIC_CONSTANT(int, min_exponent = limits_type::min_exponent);
BOOST_STATIC_CONSTANT(int, min_exponent10 = limits_type::min_exponent10);
BOOST_STATIC_CONSTANT(int, max_exponent = limits_type::max_exponent);
BOOST_STATIC_CONSTANT(int, max_exponent10 = limits_type::max_exponent10);
BOOST_STATIC_CONSTANT(bool, has_infinity = limits_type::has_infinity);
BOOST_STATIC_CONSTANT(bool, has_quiet_NaN = limits_type::has_quiet_NaN);
BOOST_STATIC_CONSTANT(bool, has_signaling_NaN = limits_type::has_signaling_NaN);
BOOST_STATIC_CONSTANT(float_denorm_style, has_denorm = limits_type::has_denorm);
BOOST_STATIC_CONSTANT(bool, has_denorm_loss = limits_type::has_denorm_loss);
static MyUnsigned1 infinity() throw() { return limits_type::infinity(); }
static MyUnsigned1 quiet_NaN() throw() { return limits_type::quiet_NaN(); }
static MyUnsigned1 signaling_NaN() throw()
{ return limits_type::signaling_NaN(); }
static MyUnsigned1 denorm_min() throw(){ return limits_type::denorm_min(); }
BOOST_STATIC_CONSTANT(bool, is_iec559 = limits_type::is_iec559);
BOOST_STATIC_CONSTANT(bool, is_bounded = limits_type::is_bounded);
BOOST_STATIC_CONSTANT(bool, is_modulo = limits_type::is_modulo);
BOOST_STATIC_CONSTANT(bool, traps = limits_type::traps);
BOOST_STATIC_CONSTANT(bool, tinyness_before = limits_type::tinyness_before);
BOOST_STATIC_CONSTANT(float_round_style, round_style = limits_type::round_style);
}; // std::numeric_limits<MyUnsigned1>
#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
// MSVC 6.0 lacks operator<< for __int64, see
// https://support.microsoft.com/kb/168440/
inline ostream& operator<<(ostream& os, __int64 i)
{
char buf[20];
sprintf(buf,"%I64d", i);
os << buf;
return os;
}
inline ostream& operator<<(ostream& os, unsigned __int64 i)
{
char buf[20];
sprintf(buf,"%I64u", i);
os << buf;
return os;
}
#endif
} // namespace std
// GCD tests
// GCD on signed integer types
template< class T > void gcd_int_test() // signed_test_types
{
#ifndef BOOST_MSVC
using boost::integer::gcd;
using boost::integer::gcd_evaluator;
#else
using namespace boost::integer;
#endif
// Originally from Boost.Rational tests
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(1), static_cast<T>(-1)), static_cast<T>( 1) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(-1), static_cast<T>(1)), static_cast<T>( 1) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(1), static_cast<T>(1)), static_cast<T>( 1) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(-1), static_cast<T>(-1)), static_cast<T>( 1) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(0), static_cast<T>(0)), static_cast<T>( 0) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(7), static_cast<T>(0)), static_cast<T>( 7) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(0), static_cast<T>(9)), static_cast<T>( 9) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(-7), static_cast<T>(0)), static_cast<T>( 7) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(0), static_cast<T>(-9)), static_cast<T>( 9) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(42), static_cast<T>(30)), static_cast<T>( 6) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(6), static_cast<T>(-9)), static_cast<T>( 3) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(-10), static_cast<T>(-10)), static_cast<T>(10) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(-25), static_cast<T>(-10)), static_cast<T>( 5) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(3), static_cast<T>(7)), static_cast<T>( 1) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(8), static_cast<T>(9)), static_cast<T>( 1) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(7), static_cast<T>(49)), static_cast<T>( 7) );
// Again with function object:
BOOST_TEST_EQ(gcd_evaluator<T>()(1, -1), static_cast<T>(1));
BOOST_TEST_EQ(gcd_evaluator<T>()(-1, 1), static_cast<T>(1));
BOOST_TEST_EQ(gcd_evaluator<T>()(1, 1), static_cast<T>(1));
BOOST_TEST_EQ(gcd_evaluator<T>()(-1, -1), static_cast<T>(1));
BOOST_TEST_EQ(gcd_evaluator<T>()(0, 0), static_cast<T>(0));
BOOST_TEST_EQ(gcd_evaluator<T>()(7, 0), static_cast<T>(7));
BOOST_TEST_EQ(gcd_evaluator<T>()(0, 9), static_cast<T>(9));
BOOST_TEST_EQ(gcd_evaluator<T>()(-7, 0), static_cast<T>(7));
BOOST_TEST_EQ(gcd_evaluator<T>()(0, -9), static_cast<T>(9));
BOOST_TEST_EQ(gcd_evaluator<T>()(42, 30), static_cast<T>(6));
BOOST_TEST_EQ(gcd_evaluator<T>()(6, -9), static_cast<T>(3));
BOOST_TEST_EQ(gcd_evaluator<T>()(-10, -10), static_cast<T>(10));
BOOST_TEST_EQ(gcd_evaluator<T>()(-25, -10), static_cast<T>(5));
BOOST_TEST_EQ(gcd_evaluator<T>()(3, 7), static_cast<T>(1));
BOOST_TEST_EQ(gcd_evaluator<T>()(8, 9), static_cast<T>(1));
BOOST_TEST_EQ(gcd_evaluator<T>()(7, 49), static_cast<T>(7));
}
// GCD on unmarked signed integer type
void gcd_unmarked_int_test()
{
#ifndef BOOST_MSVC
using boost::integer::gcd;
#else
using namespace boost::integer;
#endif
// The regular signed-integer GCD function performs the unsigned version,
// then does an absolute-value on the result. Signed types that are not
// marked as such (due to no std::numeric_limits specialization) may be off
// by a sign.
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(1), static_cast<MyInt2>(-1) )), MyInt2( 1) );
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(-1), static_cast<MyInt2>(1) )), MyInt2( 1) );
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(1), static_cast<MyInt2>(1) )), MyInt2( 1) );
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(-1), static_cast<MyInt2>(-1) )), MyInt2( 1) );
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(0), static_cast<MyInt2>(0) )), MyInt2( 0) );
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(7), static_cast<MyInt2>(0) )), MyInt2( 7) );
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(0), static_cast<MyInt2>(9) )), MyInt2( 9) );
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(-7), static_cast<MyInt2>(0) )), MyInt2( 7) );
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(0), static_cast<MyInt2>(-9) )), MyInt2( 9) );
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(42), static_cast<MyInt2>(30))), MyInt2( 6) );
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(6), static_cast<MyInt2>(-9) )), MyInt2( 3) );
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(-10), static_cast<MyInt2>(-10) )), MyInt2(10) );
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(-25), static_cast<MyInt2>(-10) )), MyInt2( 5) );
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(3), static_cast<MyInt2>(7) )), MyInt2( 1) );
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(8), static_cast<MyInt2>(9) )), MyInt2( 1) );
BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(7), static_cast<MyInt2>(49) )), MyInt2( 7) );
}
// GCD on unsigned integer types
template< class T > void gcd_unsigned_test() // unsigned_test_types
{
#ifndef BOOST_MSVC
using boost::integer::gcd;
#else
using namespace boost::integer;
#endif
// Note that unmarked types (i.e. have no std::numeric_limits
// specialization) are treated like non/unsigned types
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(1u), static_cast<T>(1u)), static_cast<T>( 1u) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(0u), static_cast<T>(0u)), static_cast<T>( 0u) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(7u), static_cast<T>(0u)), static_cast<T>( 7u) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(0u), static_cast<T>(9u)), static_cast<T>( 9u) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(42u), static_cast<T>(30u)), static_cast<T>( 6u) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(3u), static_cast<T>(7u)), static_cast<T>( 1u) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(8u), static_cast<T>(9u)), static_cast<T>( 1u) );
BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(7u), static_cast<T>(49u)), static_cast<T>( 7u) );
}
// GCD at compile-time
void gcd_static_test()
{
#ifndef BOOST_MSVC
using boost::integer::static_gcd;
#else
using namespace boost::integer;
#endif
// Can't use "BOOST_TEST_EQ", otherwise the "value" member will be
// disqualified as compile-time-only constant, needing explicit definition
BOOST_TEST( (static_gcd< 1, 1>::value) == 1 );
BOOST_TEST( (static_gcd< 0, 0>::value) == 0 );
BOOST_TEST( (static_gcd< 7, 0>::value) == 7 );
BOOST_TEST( (static_gcd< 0, 9>::value) == 9 );
BOOST_TEST( (static_gcd<42, 30>::value) == 6 );
BOOST_TEST( (static_gcd< 3, 7>::value) == 1 );
BOOST_TEST( (static_gcd< 8, 9>::value) == 1 );
BOOST_TEST( (static_gcd< 7, 49>::value) == 7 );
}
void gcd_method_test()
{
// Verify that the 3 different methods all yield the same result:
boost::random::mt19937 gen;
boost::random::uniform_int_distribution<int> d(0, ((std::numeric_limits<int>::max)() / 2));
for (unsigned int i = 0; i < 10000; ++i)
{
int v1 = d(gen);
int v2 = d(gen);
int g = boost::integer::gcd_detail::Euclid_gcd(v1, v2);
BOOST_TEST(v1 % g == 0);
BOOST_TEST(v2 % g == 0);
BOOST_TEST_EQ(g, boost::integer::gcd_detail::mixed_binary_gcd(v1, v2));
BOOST_TEST_EQ(g, boost::integer::gcd_detail::Stein_gcd(v1, v2));
}
}
// LCM tests
// LCM on signed integer types
template< class T > void lcm_int_test() // signed_test_types
{
#ifndef BOOST_MSVC
using boost::integer::lcm;
using boost::integer::lcm_evaluator;
#else
using namespace boost::integer;
#endif
// Originally from Boost.Rational tests
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(1), static_cast<T>(-1)), static_cast<T>( 1) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(-1), static_cast<T>(1)), static_cast<T>( 1) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(1), static_cast<T>(1)), static_cast<T>( 1) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(-1), static_cast<T>(-1)), static_cast<T>( 1) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(0), static_cast<T>(0)), static_cast<T>( 0) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(6), static_cast<T>(0)), static_cast<T>( 0) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(0), static_cast<T>(7)), static_cast<T>( 0) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(-5), static_cast<T>(0)), static_cast<T>( 0) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(0), static_cast<T>(-4)), static_cast<T>( 0) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(18), static_cast<T>(30)), static_cast<T>(90) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(-6), static_cast<T>(9)), static_cast<T>(18) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(-10), static_cast<T>(-10)), static_cast<T>(10) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(25), static_cast<T>(-10)), static_cast<T>(50) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(3), static_cast<T>(7)), static_cast<T>(21) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(8), static_cast<T>(9)), static_cast<T>(72) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(7), static_cast<T>(49)), static_cast<T>(49) );
// Again with function object:
BOOST_TEST_EQ(lcm_evaluator<T>()(1, -1), static_cast<T>(1));
BOOST_TEST_EQ(lcm_evaluator<T>()(-1, 1), static_cast<T>(1));
BOOST_TEST_EQ(lcm_evaluator<T>()(1, 1), static_cast<T>(1));
BOOST_TEST_EQ(lcm_evaluator<T>()(-1, -1), static_cast<T>(1));
BOOST_TEST_EQ(lcm_evaluator<T>()(0, 0), static_cast<T>(0));
BOOST_TEST_EQ(lcm_evaluator<T>()(6, 0), static_cast<T>(0));
BOOST_TEST_EQ(lcm_evaluator<T>()(0, 7), static_cast<T>(0));
BOOST_TEST_EQ(lcm_evaluator<T>()(-5, 0), static_cast<T>(0));
BOOST_TEST_EQ(lcm_evaluator<T>()(0, -4), static_cast<T>(0));
BOOST_TEST_EQ(lcm_evaluator<T>()(18, 30), static_cast<T>(90));
BOOST_TEST_EQ(lcm_evaluator<T>()(-6, 9), static_cast<T>(18));
BOOST_TEST_EQ(lcm_evaluator<T>()(-10, -10), static_cast<T>(10));
BOOST_TEST_EQ(lcm_evaluator<T>()(25, -10), static_cast<T>(50));
BOOST_TEST_EQ(lcm_evaluator<T>()(3, 7), static_cast<T>(21));
BOOST_TEST_EQ(lcm_evaluator<T>()(8, 9), static_cast<T>(72));
BOOST_TEST_EQ(lcm_evaluator<T>()(7, 49), static_cast<T>(49));
}
// LCM on unmarked signed integer type
void lcm_unmarked_int_test()
{
#ifndef BOOST_MSVC
using boost::integer::lcm;
#else
using namespace boost::integer;
#endif
// The regular signed-integer LCM function performs the unsigned version,
// then does an absolute-value on the result. Signed types that are not
// marked as such (due to no std::numeric_limits specialization) may be off
// by a sign.
BOOST_TEST_EQ( abs(boost::integer::lcm( static_cast<MyInt2>(1), static_cast<MyInt2>(-1) )), MyInt2( 1) );
BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(-1), static_cast<MyInt2>(1) )), MyInt2( 1) );
BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(1), static_cast<MyInt2>(1) )), MyInt2( 1) );
BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(-1), static_cast<MyInt2>(-1) )), MyInt2( 1) );
BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(0), static_cast<MyInt2>(0) )), MyInt2( 0) );
BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(6), static_cast<MyInt2>(0) )), MyInt2( 0) );
BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(0), static_cast<MyInt2>(7) )), MyInt2( 0) );
BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(-5), static_cast<MyInt2>(0) )), MyInt2( 0) );
BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(0), static_cast<MyInt2>(-4) )), MyInt2( 0) );
BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(18), static_cast<MyInt2>(30) )), MyInt2(90) );
BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(-6), static_cast<MyInt2>(9) )), MyInt2(18) );
BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(-10), static_cast<MyInt2>(-10) )), MyInt2(10) );
BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(25), static_cast<MyInt2>(-10) )), MyInt2(50) );
BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(3), static_cast<MyInt2>(7) )), MyInt2(21) );
BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(8), static_cast<MyInt2>(9) )), MyInt2(72) );
BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(7), static_cast<MyInt2>(49) )), MyInt2(49) );
}
// LCM on unsigned integer types
template< class T > void lcm_unsigned_test() // unsigned_test_types
{
#ifndef BOOST_MSVC
using boost::integer::lcm;
#else
using namespace boost::integer;
#endif
// Note that unmarked types (i.e. have no std::numeric_limits
// specialization) are treated like non/unsigned types
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(1u), static_cast<T>(1u)), static_cast<T>( 1u) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(0u), static_cast<T>(0u)), static_cast<T>( 0u) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(6u), static_cast<T>(0u)), static_cast<T>( 0u) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(0u), static_cast<T>(7u)), static_cast<T>( 0u) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(18u), static_cast<T>(30u)), static_cast<T>(90u) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(3u), static_cast<T>(7u)), static_cast<T>(21u) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(8u), static_cast<T>(9u)), static_cast<T>(72u) );
BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(7u), static_cast<T>(49u)), static_cast<T>(49u) );
}
// LCM at compile-time
void lcm_static_test()
{
#ifndef BOOST_MSVC
using boost::integer::static_lcm;
#else
using namespace boost::integer;
#endif
// Can't use "BOOST_TEST_EQ", otherwise the "value" member will be
// disqualified as compile-time-only constant, needing explicit definition
BOOST_TEST( (static_lcm< 1, 1>::value) == 1 );
BOOST_TEST( (static_lcm< 0, 0>::value) == 0 );
BOOST_TEST( (static_lcm< 6, 0>::value) == 0 );
BOOST_TEST( (static_lcm< 0, 7>::value) == 0 );
BOOST_TEST( (static_lcm<18, 30>::value) == 90 );
BOOST_TEST( (static_lcm< 3, 7>::value) == 21 );
BOOST_TEST( (static_lcm< 8, 9>::value) == 72 );
BOOST_TEST( (static_lcm< 7, 49>::value) == 49 );
}
void variadics()
{
unsigned i[] = { 44, 56, 76, 88 };
BOOST_TEST_EQ(boost::integer::gcd_range(i, i + 4).first, 4);
BOOST_TEST_EQ(boost::integer::gcd_range(i, i + 4).second, i + 4);
BOOST_TEST_EQ(boost::integer::lcm_range(i, i + 4).first, 11704);
BOOST_TEST_EQ(boost::integer::lcm_range(i, i + 4).second, i + 4);
unsigned i_gcd_unity[] = { 44, 56, 1, 88 };
BOOST_TEST_EQ(boost::integer::gcd_range(i_gcd_unity, i_gcd_unity + 4).first, 1);
BOOST_TEST_EQ(boost::integer::gcd_range(i_gcd_unity, i_gcd_unity + 4).second, i_gcd_unity + 3);
unsigned i_lcm_unity[] = { 44, 56, 0, 88 };
BOOST_TEST_EQ(boost::integer::lcm_range(i_lcm_unity, i_lcm_unity + 4).first, 0);
BOOST_TEST_EQ(boost::integer::lcm_range(i_lcm_unity, i_lcm_unity + 4).second, i_lcm_unity + 3);
#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
BOOST_TEST_EQ(boost::integer::gcd(i[0], i[1], i[2], i[3]), 4);
BOOST_TEST_EQ(boost::integer::lcm(i[0], i[1], i[2], i[3]), 11704);
#endif
}
// Test case from Boost.Rational, need to make sure we don't break the rational lib:
template <class T> void gcd_and_lcm_on_rationals()
{
typedef boost::rational<T> rational;
BOOST_TEST_EQ(boost::integer::gcd(rational(1, 4), rational(1, 3)),
rational(1, 12));
BOOST_TEST_EQ(boost::integer::lcm(rational(1, 4), rational(1, 3)),
rational(1));
}
#ifndef DISABLE_MP_TESTS
#define TEST_SIGNED_( test ) \
test<signed char>(); \
test<short>(); \
test<int>(); \
test<long>(); \
test<MyInt1>(); \
test<boost::multiprecision::cpp_int>(); \
test<boost::multiprecision::int512_t>();
#else
#define TEST_SIGNED_( test ) \
test<signed char>(); \
test<short>(); \
test<int>(); \
test<long>(); \
test<MyInt1>();
#endif
#ifdef BOOST_HAS_LONG_LONG
# define TEST_SIGNED__( test ) \
TEST_SIGNED_( test ) \
test<boost::long_long_type>();
#elif defined(BOOST_HAS_MS_INT64)
# define TEST_SIGNED__( test ) \
TEST_SIGNED_( test ) \
test<__int64>();
#endif
#ifndef DISABLE_MP_TESTS
#define TEST_UNSIGNED_( test ) \
test<unsigned char>(); \
test<unsigned short>(); \
test<unsigned>(); \
test<unsigned long>(); \
test<MyUnsigned1>(); \
test<MyUnsigned2>(); \
test<boost::multiprecision::uint512_t>();
#else
#define TEST_UNSIGNED_( test ) \
test<unsigned char>(); \
test<unsigned short>(); \
test<unsigned>(); \
test<unsigned long>(); \
test<MyUnsigned1>(); \
test<MyUnsigned2>();
#endif
#ifdef BOOST_HAS_LONG_LONG
# define TEST_UNSIGNED( test ) \
TEST_UNSIGNED_( test ) \
test<boost::ulong_long_type>();
#elif defined(BOOST_HAS_MS_INT64)
# define TEST_UNSIGNED( test ) \
TEST_UNSIGNED_( test ) \
test<unsigned __int64>();
#endif
#ifdef BOOST_INTEGER_HAS_GMPXX_H
# define TEST_SIGNED(test)\
TEST_SIGNED__(test)\
test<mpz_class>();
# define TEST_SIGNED_NO_GMP(test) TEST_SIGNED__(test)
#else
# define TEST_SIGNED(test) TEST_SIGNED__(test)
# define TEST_SIGNED_NO_GMP(test) TEST_SIGNED__(test)
#endif
int main()
{
TEST_SIGNED(gcd_int_test)
gcd_unmarked_int_test();
TEST_UNSIGNED(gcd_unsigned_test)
gcd_static_test();
gcd_method_test();
TEST_SIGNED(lcm_int_test)
lcm_unmarked_int_test();
TEST_UNSIGNED(lcm_unsigned_test)
lcm_static_test();
variadics();
TEST_SIGNED_NO_GMP(gcd_and_lcm_on_rationals)
return boost::report_errors();
}

View File

@ -0,0 +1,58 @@
/*
* (C) Copyright Nick Thompson 2018.
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
*/
#include "multiprecision_config.hpp"
#ifndef DISABLE_MP_TESTS
#include <boost/integer/extended_euclidean.hpp>
#include <boost/cstdint.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/integer/common_factor.hpp>
using boost::multiprecision::int128_t;
using boost::multiprecision::int256_t;
using boost::integer::extended_euclidean;
using boost::integer::gcd;
template<class Z>
void test_extended_euclidean()
{
// Stress test:
//Z max_arg = std::numeric_limits<Z>::max();
Z max_arg = 500;
for (Z m = max_arg; m > 0; --m)
{
for (Z n = max_arg; n > 0; --n)
{
boost::integer::euclidean_result_t<Z> u = extended_euclidean(m, n);
int256_t gcdmn = gcd(m, n);
int256_t x = u.x;
int256_t y = u.y;
BOOST_TEST_EQ(u.gcd, gcdmn);
BOOST_TEST_EQ(m*x + n*y, gcdmn);
}
}
}
int main()
{
test_extended_euclidean<boost::int16_t>();
test_extended_euclidean<boost::int32_t>();
test_extended_euclidean<boost::int64_t>();
test_extended_euclidean<int128_t>();
return boost::report_errors();;
}
#else
int main()
{
return 0;
}
#endif

8
test/fail_int_exact.cpp Normal file
View File

@ -0,0 +1,8 @@
// Copyright John Maddock 2012.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp>
typedef boost::int_t<sizeof(boost::intmax_t)*CHAR_BIT + 1>::exact fail_int_exact;

8
test/fail_int_fast.cpp Normal file
View File

@ -0,0 +1,8 @@
// Copyright John Maddock 2012.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp>
typedef boost::int_t<sizeof(boost::intmax_t)*CHAR_BIT + 1>::fast fail_int_fast;

8
test/fail_int_least.cpp Normal file
View File

@ -0,0 +1,8 @@
// Copyright John Maddock 2012.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp>
typedef boost::int_t<sizeof(boost::intmax_t)*CHAR_BIT + 1>::least fail_int_least;

13
test/fail_uint_65.cpp Normal file
View File

@ -0,0 +1,13 @@
// Copyright John Maddock 2012.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp>
#include <iostream>
int main()
{
std::cout << std::numeric_limits<boost::uint_t<65>::least>::digits;
return 0;
}

8
test/fail_uint_exact.cpp Normal file
View File

@ -0,0 +1,8 @@
// Copyright John Maddock 2012.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp>
typedef boost::uint_t<sizeof(boost::intmax_t)*CHAR_BIT + 1>::exact fail_uint_exact;

8
test/fail_uint_fast.cpp Normal file
View File

@ -0,0 +1,8 @@
// Copyright John Maddock 2012.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp>
typedef boost::uint_t<sizeof(boost::intmax_t)*CHAR_BIT + 1>::fast fail_uint_fast;

8
test/fail_uint_least.cpp Normal file
View File

@ -0,0 +1,8 @@
// Copyright John Maddock 2012.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp>
typedef boost::uint_t<sizeof(boost::intmax_t)*CHAR_BIT + 1>::least fail_uint_least;

View File

@ -0,0 +1,66 @@
// (C) Copyright John Maddock 2017.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer/common_factor.hpp>
#ifndef BOOST_NO_CXX14_CONSTEXPR
void test_constexpr1()
{
constexpr const boost::int64_t i = 347 * 463 * 727;
constexpr const boost::int64_t j = 191 * 347 * 281;
constexpr const boost::int64_t k = boost::integer::gcd(i, j);
constexpr const boost::int64_t l = boost::integer::lcm(i, j);
static_assert(k == 347, "Expected result not integer in constexpr gcd.");
static_assert(l == 6268802158037, "Expected result not integer in constexpr lcm.");
}
void test_constexpr2()
{
constexpr const boost::uint64_t i = 347 * 463 * 727;
constexpr const boost::uint64_t j = 191 * 347 * 281;
constexpr const boost::uint64_t k = boost::integer::gcd(i, j);
constexpr const boost::uint64_t l = boost::integer::lcm(i, j);
static_assert(k == 347, "Expected result not integer in constexpr gcd.");
static_assert(l == 6268802158037, "Expected result not integer in constexpr lcm.");
}
void test_constexpr3()
{
constexpr const boost::uint64_t i = 347 * 463 * 727;
constexpr const boost::uint64_t j = 191 * 347 * 281;
constexpr const boost::uint64_t k = boost::integer::gcd_detail::Euclid_gcd(i, j);
static_assert(k == 347, "Expected result not integer in constexpr gcd.");
}
void test_constexpr4()
{
constexpr const boost::uint64_t i = 347 * 463 * 727;
constexpr const boost::uint64_t j = 191 * 347 * 281;
constexpr const boost::uint64_t k = boost::integer::gcd_detail::mixed_binary_gcd(i, j);
static_assert(k == 347, "Expected result not integer in constexpr gcd.");
}
void test_constexpr5()
{
constexpr const boost::uint64_t i = 347 * 463 * 727;
constexpr const boost::uint64_t j = 191 * 347 * 281;
constexpr const boost::uint64_t k = boost::integer::gcd_detail::Stein_gcd(i, j);
static_assert(k == 347, "Expected result not integer in constexpr gcd.");
}
#endif

View File

@ -0,0 +1,35 @@
// (C) Copyright John Maddock 2017.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer/common_factor.hpp>
#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
//
// These tests don't pass with GCC-4.x:
//
#if !defined(BOOST_GCC) || (BOOST_GCC >= 50000)
void test_noexcept(unsigned char a, unsigned char b)
{
static_assert(noexcept(boost::integer::gcd(static_cast<unsigned char>(a), static_cast<unsigned char>(b))), "Expected a noexcept function.");
#ifndef _MSC_VER
// This generates an internal compiler error if enabled as well as the following test:
static_assert(noexcept(boost::integer::gcd(static_cast<char>(a), static_cast<char>(b))), "Expected a noexcept function.");
#endif
static_assert(noexcept(boost::integer::gcd(static_cast<signed char>(a), static_cast<signed char>(b))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<short>(a), static_cast<short>(b))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<unsigned short>(a), static_cast<unsigned short>(b))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<int>(a), static_cast<int>(b))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<unsigned int>(a), static_cast<unsigned int>(b))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<long>(a), static_cast<long>(b))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<unsigned long>(a), static_cast<unsigned long>(b))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<long long>(a), static_cast<long long>(b))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<unsigned long long>(a), static_cast<unsigned long long>(b))), "Expected a noexcept function.");
}
#endif
#endif

15
test/has_gmpxx.cpp Normal file
View File

@ -0,0 +1,15 @@
// Copyright John Maddock 2008.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include <gmpxx.h>
// On Linux, libgmpxx is built with gcc and libstdc++. When the user application, such as tests, are built against libc++,
// linking fails because of the C++ standard library symbol names mismatch. So fail the test if we're not using libstdc++.
#if defined(__linux__) || defined(__linux) || defined(linux)
#include <utility>
#if !defined(__GLIBCPP__) && !defined(__GLIBCXX__)
#error "libgmpxx is not supported on this platform with this C++ standard library"
#endif
#endif

View File

@ -0,0 +1,22 @@
// Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer_fwd.hpp> // must be the only #include!
// just declare some functions that use the incomplete types in the header:
void f1(const boost::integer_traits<char>*);
void f2(const boost::int_fast_t<char>*);
void f3(const boost::int_t<12>*);
void f4(const boost::uint_t<31>*);
void f5(const boost::int_max_value_t<100>*);
void f6(const boost::int_min_value_t<-100>*);
void f7(const boost::uint_value_t<100>*);
void f8(const boost::high_bit_mask_t<10>*);
void f9(const boost::low_bits_mask_t<10>*);
void f10(boost::static_log2_argument_type, boost::static_log2_result_type, boost::static_log2<10>*);
void f11(boost::static_min_max_signed_type, boost::static_min_max_unsigned_type);
void f12(boost::static_signed_min<1, 2>*, boost::static_signed_max<1,2>*);
void f13(boost::static_unsigned_min<1,2>*, boost::static_unsigned_min<1,2>*);

View File

@ -0,0 +1,36 @@
// Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp> // must be the only #include!
int main()
{
boost::int_fast_t<char>::fast f = 0;
(void)f;
boost::int_t<16>::fast f2 = 0;
(void)f2;
boost::int_t<32>::exact e = 0;
(void)e;
boost::int_t<12>::least l = 0;
(void)l;
boost::uint_t<16>::fast uf2 = 0;
(void)uf2;
boost::uint_t<32>::exact ue = 0;
(void)ue;
boost::uint_t<12>::least ul = 0;
(void)ul;
boost::int_max_value_t<200>::fast v1 = 0;
(void)v1;
boost::int_max_value_t<2000>::least v2 = 0;
(void)v2;
boost::int_min_value_t<-200>::fast v3 = 0;
(void)v3;
boost::int_min_value_t<-2000>::least v4 = 0;
(void)v4;
boost::uint_value_t<200>::fast v5 = 0;
(void)v5;
boost::uint_value_t<2000>::least v6 = 0;
(void)v6;
}

187
test/integer_log2_test.cpp Normal file
View File

@ -0,0 +1,187 @@
// Boost integer_log2.hpp test program --------------------------------------//
// (C) Copyright Andrey Semashev 2021.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org for most recent version including documentation.
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/integer/integer_log2.hpp>
#include <boost/core/lightweight_test.hpp>
#include <iostream>
#include "multiprecision_config.hpp"
#if !defined(DISABLE_MP_TESTS)
#include <boost/multiprecision/cpp_int.hpp>
#endif
// Macros to compact code
#define PRIVATE_LB_TEST( v, e ) BOOST_TEST( ::boost::integer_log2((v)) == e )
#define PRIVATE_PRINT_LB( v ) ::std::cout << "boost::integer_log2(" << (v) \
<< ") = " << ::boost::integer_log2((v)) << '.' << ::std::endl
// Control to check for a compile-time error
#ifndef CONTROL_LB_0_TEST
#define PRIVATE_LB_0_TEST
#else
#define PRIVATE_LB_0_TEST PRIVATE_PRINT_LB( 0 )
#endif
// Main testing function
int main()
{
std::cout << "Doing tests on integer_log2." << std::endl;
PRIVATE_LB_0_TEST;
PRIVATE_LB_TEST( (unsigned char)1, 0 );
PRIVATE_LB_TEST( (unsigned char)2, 1 );
PRIVATE_LB_TEST( 1, 0 );
PRIVATE_LB_TEST( 2, 1 );
PRIVATE_LB_TEST( 3, 1 );
PRIVATE_LB_TEST( 4, 2 );
PRIVATE_LB_TEST( 5, 2 );
PRIVATE_LB_TEST( 6, 2 );
PRIVATE_LB_TEST( 7, 2 );
PRIVATE_LB_TEST( 8, 3 );
PRIVATE_LB_TEST( 9, 3 );
PRIVATE_LB_TEST( 10, 3 );
PRIVATE_LB_TEST( 11, 3 );
PRIVATE_LB_TEST( 12, 3 );
PRIVATE_LB_TEST( 13, 3 );
PRIVATE_LB_TEST( 14, 3 );
PRIVATE_LB_TEST( 15, 3 );
PRIVATE_LB_TEST( 16, 4 );
PRIVATE_LB_TEST( 17, 4 );
PRIVATE_LB_TEST( 18, 4 );
PRIVATE_LB_TEST( 19, 4 );
PRIVATE_LB_TEST( 20, 4 );
PRIVATE_LB_TEST( 21, 4 );
PRIVATE_LB_TEST( 22, 4 );
PRIVATE_LB_TEST( 23, 4 );
PRIVATE_LB_TEST( 24, 4 );
PRIVATE_LB_TEST( 25, 4 );
PRIVATE_LB_TEST( 26, 4 );
PRIVATE_LB_TEST( 27, 4 );
PRIVATE_LB_TEST( 28, 4 );
PRIVATE_LB_TEST( 29, 4 );
PRIVATE_LB_TEST( 30, 4 );
PRIVATE_LB_TEST( 31, 4 );
PRIVATE_LB_TEST( 32, 5 );
PRIVATE_LB_TEST( 33, 5 );
PRIVATE_LB_TEST( 34, 5 );
PRIVATE_LB_TEST( 35, 5 );
PRIVATE_LB_TEST( 36, 5 );
PRIVATE_LB_TEST( 37, 5 );
PRIVATE_LB_TEST( 38, 5 );
PRIVATE_LB_TEST( 39, 5 );
PRIVATE_LB_TEST( 40, 5 );
PRIVATE_LB_TEST( 63, 5 );
PRIVATE_LB_TEST( 64, 6 );
PRIVATE_LB_TEST( 65, 6 );
PRIVATE_LB_TEST( 127, 6 );
PRIVATE_LB_TEST( 128, 7 );
PRIVATE_LB_TEST( 129, 7 );
PRIVATE_LB_TEST( 255, 7 );
PRIVATE_LB_TEST( 256, 8 );
PRIVATE_LB_TEST( 257, 8 );
PRIVATE_LB_TEST( 511, 8 );
PRIVATE_LB_TEST( 512, 9 );
PRIVATE_LB_TEST( 513, 9 );
PRIVATE_LB_TEST( 1023, 9 );
PRIVATE_LB_TEST( 1024, 10 );
PRIVATE_LB_TEST( 1025, 10 );
PRIVATE_LB_TEST( 2047, 10 );
PRIVATE_LB_TEST( 2048, 11 );
PRIVATE_LB_TEST( 2049, 11 );
PRIVATE_LB_TEST( 4095, 11 );
PRIVATE_LB_TEST( 4096, 12 );
PRIVATE_LB_TEST( 4097, 12 );
PRIVATE_LB_TEST( 8191, 12 );
PRIVATE_LB_TEST( 8192, 13 );
PRIVATE_LB_TEST( 8193, 13 );
PRIVATE_LB_TEST( 16383, 13 );
PRIVATE_LB_TEST( 16384, 14 );
PRIVATE_LB_TEST( 16385, 14 );
PRIVATE_LB_TEST( 32767, 14 );
PRIVATE_LB_TEST( 32768, 15 );
PRIVATE_LB_TEST( 32769, 15 );
PRIVATE_LB_TEST( 65535, 15 );
PRIVATE_LB_TEST( 65536, 16 );
PRIVATE_LB_TEST( 65537, 16 );
#if defined(UINT32_C)
PRIVATE_LB_TEST( UINT32_C(4294967295), 31 );
#endif
#if defined(UINT64_C) && !defined(BOOST_NO_INT64_T)
PRIVATE_LB_TEST( UINT64_C(4294967296), 32 );
PRIVATE_LB_TEST( UINT64_C(4294967297), 32 );
PRIVATE_LB_TEST( UINT64_C(18446744073709551615), 63 );
#endif
#if defined(BOOST_HAS_INT128)
PRIVATE_LB_TEST( boost::uint128_type(1u) << 64u, 64 );
PRIVATE_LB_TEST( (boost::uint128_type(1u) << 64u) + 1u, 64 );
PRIVATE_LB_TEST( ~boost::uint128_type(0u), 127 );
#endif
#if !defined(DISABLE_MP_TESTS)
PRIVATE_LB_TEST( boost::multiprecision::cpp_int(1), 0 );
PRIVATE_LB_TEST( boost::multiprecision::cpp_int(2), 1 );
PRIVATE_LB_TEST( boost::multiprecision::cpp_int(3), 1 );
PRIVATE_LB_TEST( boost::multiprecision::cpp_int(65535), 15 );
PRIVATE_LB_TEST( boost::multiprecision::cpp_int(65536), 16 );
PRIVATE_LB_TEST( boost::multiprecision::int1024_t(1), 0 );
PRIVATE_LB_TEST( boost::multiprecision::int1024_t(2), 1 );
PRIVATE_LB_TEST( boost::multiprecision::int1024_t(3), 1 );
PRIVATE_LB_TEST( boost::multiprecision::int1024_t(65535), 15 );
PRIVATE_LB_TEST( boost::multiprecision::int1024_t(65536), 16 );
PRIVATE_LB_TEST( boost::multiprecision::uint1024_t(1), 0 );
PRIVATE_LB_TEST( boost::multiprecision::uint1024_t(2), 1 );
PRIVATE_LB_TEST( boost::multiprecision::uint1024_t(3), 1 );
PRIVATE_LB_TEST( boost::multiprecision::uint1024_t(65535), 15 );
PRIVATE_LB_TEST( boost::multiprecision::uint1024_t(65536), 16 );
#endif
return boost::report_errors();
}

View File

@ -0,0 +1,18 @@
// Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer/integer_mask.hpp> // must be the only #include!
int main()
{
boost::high_bit_mask_t<20>::least l = boost::high_bit_mask_t<20>::high_bit;
boost::high_bit_mask_t<12>::fast f = boost::high_bit_mask_t<12>::high_bit_fast;
l += f + boost::high_bit_mask_t<12>::bit_position;
(void)l;
boost::low_bits_mask_t<20>::least l2 = boost::low_bits_mask_t<20>::sig_bits;
boost::low_bits_mask_t<12>::fast f2 = boost::low_bits_mask_t<12>::sig_bits_fast;
l2 += f2 + boost::low_bits_mask_t<12>::bit_count;
(void)l2;
}

View File

@ -1,46 +1,102 @@
// boost integer_mask.hpp test program -------------------------------------//
// (C) Copyright Daryle Walker 2001. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// (C) Copyright Daryle Walker 2001.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for most recent version including documentation.
// See https://www.boost.org for most recent version including documentation.
// Revision History
// 23 Sep 2001 Initial version (Daryle Walker)
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp> // for main
#include <boost/core/lightweight_test.hpp>
#include <boost/cstdlib.hpp> // for boost::exit_success
#include <boost/integer/integer_mask.hpp> // for boost::high_bit_mask_t, etc.
#include <iostream> // for std::cout (std::endl indirectly)
#ifdef BOOST_MSVC
#pragma warning(disable:4127) // conditional expression is constant
#endif
#if defined(BOOST_HAS_LONG_LONG)
#define MASK_TYPE ::boost::ulong_long_type
#elif defined(BOOST_HAS_MS_INT64)
#define MASK_TYPE unsigned __int64
#else
#define MASK_TYPE unsigned long
#endif
#define ONE (static_cast<MASK_TYPE>(1))
#define PRIVATE_HIGH_BIT_SLOW_TEST(v) BOOST_TEST( ::boost::high_bit_mask_t< \
(v) >::high_bit == (1ul << (v)) );
(v) >::high_bit == (ONE << (v)) );
#define PRIVATE_HIGH_BIT_FAST_TEST(v) BOOST_TEST( ::boost::high_bit_mask_t< \
(v) >::high_bit_fast == (1ul << (v)) );
(v) >::high_bit_fast == (ONE << (v)) );
#define PRIVATE_HIGH_BIT_TEST(v) do { PRIVATE_HIGH_BIT_SLOW_TEST(v); \
PRIVATE_HIGH_BIT_FAST_TEST(v); } while (false)
#define PRIVATE_LOW_BITS_SLOW_TEST(v) BOOST_TEST( ::boost::low_bits_mask_t< \
(v) >::sig_bits == ((1ul << (v)) - 1) );
#define PRIVATE_LOW_BITS_FAST_TEST(v) BOOST_TEST( ::boost::low_bits_mask_t< \
(v) >::sig_bits_fast == ((1ul << (v)) - 1) );
#define PRIVATE_LOW_BITS_SLOW_TEST(v) \
do{ \
MASK_TYPE mask = 0;\
if(v > 0)\
{ mask = ((ONE << (v-1)) - 1); mask <<= 1; mask |= 1; }\
BOOST_TEST( ::boost::low_bits_mask_t< (v) >::sig_bits == mask); \
}while(false);
#define PRIVATE_LOW_BITS_FAST_TEST(v) \
do{ \
MASK_TYPE mask = 0;\
if(v > 0)\
{ mask = ((ONE << (v-1)) - 1); mask <<= 1; mask |= 1; }\
BOOST_TEST( ::boost::low_bits_mask_t< (v) >::sig_bits_fast == mask);\
}while(false);
#define PRIVATE_LOW_BITS_TEST(v) do { PRIVATE_LOW_BITS_SLOW_TEST(v); \
PRIVATE_LOW_BITS_FAST_TEST(v); } while (false)
int test_main( int, char*[] )
int main( int, char*[] )
{
using std::cout;
using std::endl;
cout << "Doing high_bit_mask_t tests." << endl;
#if defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)
PRIVATE_HIGH_BIT_TEST( 63 );
PRIVATE_HIGH_BIT_TEST( 62 );
PRIVATE_HIGH_BIT_TEST( 61 );
PRIVATE_HIGH_BIT_TEST( 60 );
PRIVATE_HIGH_BIT_TEST( 59 );
PRIVATE_HIGH_BIT_TEST( 58 );
PRIVATE_HIGH_BIT_TEST( 57 );
PRIVATE_HIGH_BIT_TEST( 56 );
PRIVATE_HIGH_BIT_TEST( 55 );
PRIVATE_HIGH_BIT_TEST( 54 );
PRIVATE_HIGH_BIT_TEST( 53 );
PRIVATE_HIGH_BIT_TEST( 52 );
PRIVATE_HIGH_BIT_TEST( 51 );
PRIVATE_HIGH_BIT_TEST( 50 );
PRIVATE_HIGH_BIT_TEST( 49 );
PRIVATE_HIGH_BIT_TEST( 48 );
PRIVATE_HIGH_BIT_TEST( 47 );
PRIVATE_HIGH_BIT_TEST( 46 );
PRIVATE_HIGH_BIT_TEST( 45 );
PRIVATE_HIGH_BIT_TEST( 44 );
PRIVATE_HIGH_BIT_TEST( 43 );
PRIVATE_HIGH_BIT_TEST( 42 );
PRIVATE_HIGH_BIT_TEST( 41 );
PRIVATE_HIGH_BIT_TEST( 40 );
PRIVATE_HIGH_BIT_TEST( 39 );
PRIVATE_HIGH_BIT_TEST( 38 );
PRIVATE_HIGH_BIT_TEST( 37 );
PRIVATE_HIGH_BIT_TEST( 36 );
PRIVATE_HIGH_BIT_TEST( 35 );
PRIVATE_HIGH_BIT_TEST( 34 );
PRIVATE_HIGH_BIT_TEST( 33 );
PRIVATE_HIGH_BIT_TEST( 32 );
#endif
PRIVATE_HIGH_BIT_TEST( 31 );
PRIVATE_HIGH_BIT_TEST( 30 );
PRIVATE_HIGH_BIT_TEST( 29 );
@ -75,7 +131,42 @@ int test_main( int, char*[] )
PRIVATE_HIGH_BIT_TEST( 0 );
cout << "Doing low_bits_mask_t tests." << endl;
PRIVATE_LOW_BITS_TEST( 32 ); // Undefined behavior? Whoops!
#if defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)
PRIVATE_LOW_BITS_TEST( 64 );
PRIVATE_LOW_BITS_TEST( 63 );
PRIVATE_LOW_BITS_TEST( 62 );
PRIVATE_LOW_BITS_TEST( 61 );
PRIVATE_LOW_BITS_TEST( 60 );
PRIVATE_LOW_BITS_TEST( 59 );
PRIVATE_LOW_BITS_TEST( 58 );
PRIVATE_LOW_BITS_TEST( 57 );
PRIVATE_LOW_BITS_TEST( 56 );
PRIVATE_LOW_BITS_TEST( 55 );
PRIVATE_LOW_BITS_TEST( 54 );
PRIVATE_LOW_BITS_TEST( 53 );
PRIVATE_LOW_BITS_TEST( 52 );
PRIVATE_LOW_BITS_TEST( 51 );
PRIVATE_LOW_BITS_TEST( 50 );
PRIVATE_LOW_BITS_TEST( 49 );
PRIVATE_LOW_BITS_TEST( 48 );
PRIVATE_LOW_BITS_TEST( 47 );
PRIVATE_LOW_BITS_TEST( 46 );
PRIVATE_LOW_BITS_TEST( 45 );
PRIVATE_LOW_BITS_TEST( 44 );
PRIVATE_LOW_BITS_TEST( 43 );
PRIVATE_LOW_BITS_TEST( 42 );
PRIVATE_LOW_BITS_TEST( 41 );
PRIVATE_LOW_BITS_TEST( 40 );
PRIVATE_LOW_BITS_TEST( 39 );
PRIVATE_LOW_BITS_TEST( 38 );
PRIVATE_LOW_BITS_TEST( 37 );
PRIVATE_LOW_BITS_TEST( 36 );
PRIVATE_LOW_BITS_TEST( 35 );
PRIVATE_LOW_BITS_TEST( 34 );
PRIVATE_LOW_BITS_TEST( 33 );
#endif
PRIVATE_LOW_BITS_TEST( 32 );
PRIVATE_LOW_BITS_TEST( 31 );
PRIVATE_LOW_BITS_TEST( 30 );
PRIVATE_LOW_BITS_TEST( 29 );
@ -108,5 +199,5 @@ int test_main( int, char*[] )
PRIVATE_LOW_BITS_TEST( 2 );
PRIVATE_LOW_BITS_TEST( 1 );
return boost::exit_success;
return boost::report_errors();
}

264
test/integer_test.cpp Normal file
View File

@ -0,0 +1,264 @@
// boost integer.hpp test program ------------------------------------------//
// Copyright Beman Dawes 1999.
// Copyright Daryle Walker 2001.
// Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org/libs/integer for documentation.
// Revision History
// 04 Oct 01 Added tests for new templates; rewrote code (Daryle Walker)
// 10 Mar 01 Boost Test Library now used for tests (Beman Dawes)
// 31 Aug 99 Initial version
#include <boost/core/lightweight_test.hpp> // for main, BOOST_TEST
#include <boost/integer.hpp> // for boost::int_t, boost::uint_t
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/bool.hpp> // for mpl::true_ and false_
#include <climits> // for ULONG_MAX, LONG_MAX, LONG_MIN
#include <iostream> // for std::cout (std::endl indirectly)
#include <typeinfo> // for std::type_info
#ifdef BOOST_MSVC
#pragma warning(disable:4127) // conditional expression is constant
#endif
#if defined( BOOST_BORLANDC )
# pragma option -w-8008 -w-8066 // condition is always true
#endif
//
// Keep track of error count, so we can print out detailed
// info only if we need it:
//
int last_error_count = 0;
//
// Helpers to print out the name of a type,
// we use these as typeid(X).name() doesn't always
// return a human readable string:
//
template <class T> const char* get_name_of_type(T){ return typeid(T).name(); }
const char* get_name_of_type(signed char){ return "signed char"; }
const char* get_name_of_type(unsigned char){ return "unsigned char"; }
const char* get_name_of_type(short){ return "short"; }
const char* get_name_of_type(unsigned short){ return "unsigned short"; }
const char* get_name_of_type(int){ return "int"; }
const char* get_name_of_type(unsigned int){ return "unsigned int"; }
const char* get_name_of_type(long){ return "long"; }
const char* get_name_of_type(unsigned long){ return "unsigned long"; }
#ifdef BOOST_HAS_LONG_LONG
const char* get_name_of_type(boost::long_long_type){ return "boost::long_long_type"; }
const char* get_name_of_type(boost::ulong_long_type){ return "boost::ulong_long_type"; }
#endif
template <int Bits>
void do_test_exact(boost::mpl::true_ const&)
{
// Test the ::exact member:
typedef typename boost::int_t<Bits>::exact int_exact;
typedef typename boost::uint_t<Bits>::exact uint_exact;
typedef typename boost::int_t<Bits>::least least_int;
typedef typename boost::uint_t<Bits>::least least_uint;
BOOST_TEST((boost::is_same<int_exact, least_int>::value));
BOOST_TEST((boost::is_same<uint_exact, least_uint>::value));
}
template <int Bits>
void do_test_exact(boost::mpl::false_ const&)
{
// Nothing to do, type does not have an ::extact member.
}
template <int Bits>
void do_test_bits()
{
//
// Recurse to next smallest number of bits:
//
do_test_bits<Bits - 1>();
//
// Test exact types if we have them:
//
do_test_exact<Bits>(
boost::mpl::bool_<
(sizeof(unsigned char) * CHAR_BIT == Bits)
|| (sizeof(unsigned short) * CHAR_BIT == Bits)
|| (sizeof(unsigned int) * CHAR_BIT == Bits)
|| (sizeof(unsigned long) * CHAR_BIT == Bits)
#ifdef BOOST_HAS_LONG_LONG
|| (sizeof(boost::ulong_long_type) * CHAR_BIT == Bits)
#endif
>());
//
// We need to check all aspects of the members of int_t<Bits> and uint_t<Bits>:
//
typedef typename boost::int_t<Bits>::least least_int;
typedef typename boost::int_t<Bits>::least fast_int;
typedef typename boost::uint_t<Bits>::least least_uint;
typedef typename boost::uint_t<Bits>::fast fast_uint;
if(std::numeric_limits<least_int>::is_specialized)
{
BOOST_TEST(std::numeric_limits<least_int>::digits + 1 >= Bits);
}
if(std::numeric_limits<least_uint>::is_specialized)
{
BOOST_TEST(std::numeric_limits<least_uint>::digits >= Bits);
}
BOOST_TEST(sizeof(least_int) * CHAR_BIT >= Bits);
BOOST_TEST(sizeof(least_uint) * CHAR_BIT >= Bits);
BOOST_TEST(sizeof(fast_int) >= sizeof(least_int));
BOOST_TEST(sizeof(fast_uint) >= sizeof(least_uint));
//
// There should be no type smaller than least_* that also has enough bits:
//
if(!boost::is_same<signed char, least_int>::value)
{
BOOST_TEST(std::numeric_limits<signed char>::digits < Bits);
if(!boost::is_same<short, least_int>::value)
{
BOOST_TEST(std::numeric_limits<short>::digits < Bits);
if(!boost::is_same<int, least_int>::value)
{
BOOST_TEST(std::numeric_limits<int>::digits < Bits);
if(!boost::is_same<long, least_int>::value)
{
BOOST_TEST(std::numeric_limits<long>::digits < Bits);
}
}
}
}
// And again, but unsigned:
if(!boost::is_same<unsigned char, least_uint>::value)
{
BOOST_TEST(std::numeric_limits<unsigned char>::digits < Bits);
if(!boost::is_same<unsigned short, least_uint>::value)
{
BOOST_TEST(std::numeric_limits<unsigned short>::digits < Bits);
if(!boost::is_same<unsigned int, least_uint>::value)
{
BOOST_TEST(std::numeric_limits<unsigned int>::digits < Bits);
if(!boost::is_same<unsigned long, least_uint>::value)
{
BOOST_TEST(std::numeric_limits<unsigned long>::digits < Bits);
}
}
}
}
if(boost::detail::test_errors() != last_error_count)
{
last_error_count = boost::detail::test_errors();
std::cout << "Errors occurred while testing with bit count = " << Bits << std::endl;
std::cout << "Type int_t<" << Bits << ">::least was " << get_name_of_type(least_int(0)) << std::endl;
std::cout << "Type int_t<" << Bits << ">::fast was " << get_name_of_type(fast_int(0)) << std::endl;
std::cout << "Type uint_t<" << Bits << ">::least was " << get_name_of_type(least_uint(0)) << std::endl;
std::cout << "Type uint_t<" << Bits << ">::fast was " << get_name_of_type(fast_uint(0)) << std::endl;
}
}
template <>
void do_test_bits<-1>()
{
// Nothing to do here!!
}
template <class Traits, class Expected>
void test_min_max_type(Expected val)
{
typedef typename Traits::least least_type;
typedef typename Traits::fast fast_type;
BOOST_TEST((boost::is_same<least_type, Expected>::value));
BOOST_TEST(sizeof(fast_type) >= sizeof(least_type));
BOOST_TEST((std::numeric_limits<least_type>::min)() <= val);
BOOST_TEST((std::numeric_limits<least_type>::max)() >= val);
if(boost::detail::test_errors() != last_error_count)
{
last_error_count = boost::detail::test_errors();
std::cout << "Traits type is: " << typeid(Traits).name() << std::endl;
std::cout << "Least type is: " << get_name_of_type(least_type(0)) << std::endl;
std::cout << "Fast type is: " << get_name_of_type(fast_type(0)) << std::endl;
std::cout << "Expected type is: " << get_name_of_type(Expected(0)) << std::endl;
std::cout << "Required value is: " << val << std::endl;
}
}
// Test program
int main(int, char*[])
{
// Test int_t and unint_t first:
if(std::numeric_limits<boost::intmax_t>::is_specialized)
do_test_bits<std::numeric_limits<boost::uintmax_t>::digits>();
else
do_test_bits<std::numeric_limits<long>::digits>();
//
// Test min and max value types:
//
test_min_max_type<boost::int_max_value_t<SCHAR_MAX>, signed char>(SCHAR_MAX);
test_min_max_type<boost::int_min_value_t<SCHAR_MIN>, signed char>(SCHAR_MIN);
test_min_max_type<boost::uint_value_t<UCHAR_MAX>, unsigned char>(UCHAR_MAX);
#if(USHRT_MAX != UCHAR_MAX)
test_min_max_type<boost::int_max_value_t<SCHAR_MAX+1>, short>(SCHAR_MAX+1);
test_min_max_type<boost::int_min_value_t<SCHAR_MIN-1>, short>(SCHAR_MIN-1);
test_min_max_type<boost::uint_value_t<UCHAR_MAX+1>, unsigned short>(UCHAR_MAX+1);
test_min_max_type<boost::int_max_value_t<SHRT_MAX>, short>(SHRT_MAX);
test_min_max_type<boost::int_min_value_t<SHRT_MIN>, short>(SHRT_MIN);
test_min_max_type<boost::uint_value_t<USHRT_MAX>, unsigned short>(USHRT_MAX);
#endif
#if(UINT_MAX != USHRT_MAX)
test_min_max_type<boost::int_max_value_t<SHRT_MAX+1>, int>(SHRT_MAX+1);
test_min_max_type<boost::int_min_value_t<SHRT_MIN-1>, int>(SHRT_MIN-1);
test_min_max_type<boost::uint_value_t<USHRT_MAX+1>, unsigned int>(USHRT_MAX+1);
test_min_max_type<boost::int_max_value_t<INT_MAX>, int>(INT_MAX);
test_min_max_type<boost::int_min_value_t<INT_MIN>, int>(INT_MIN);
test_min_max_type<boost::uint_value_t<UINT_MAX>, unsigned int>(UINT_MAX);
#endif
#if(ULONG_MAX != UINT_MAX)
test_min_max_type<boost::int_max_value_t<INT_MAX+1L>, long>(INT_MAX+1L);
test_min_max_type<boost::int_min_value_t<INT_MIN-1L>, long>(INT_MIN-1L);
test_min_max_type<boost::uint_value_t<UINT_MAX+1uL>, unsigned long>(UINT_MAX+1uL);
test_min_max_type<boost::int_max_value_t<LONG_MAX>, long>(LONG_MAX);
test_min_max_type<boost::int_min_value_t<LONG_MIN>, long>(LONG_MIN);
test_min_max_type<boost::uint_value_t<ULONG_MAX>, unsigned long>(ULONG_MAX);
#endif
#ifndef BOOST_NO_INTEGRAL_INT64_T
#if defined(BOOST_HAS_LONG_LONG) && (defined(ULLONG_MAX) && (ULLONG_MAX != ULONG_MAX))
test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, boost::long_long_type>(LONG_MAX+1LL);
test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, boost::long_long_type>(LONG_MIN-1LL);
test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, boost::ulong_long_type>(ULONG_MAX+1uLL);
test_min_max_type<boost::int_max_value_t<LLONG_MAX>, boost::long_long_type>(LLONG_MAX);
test_min_max_type<boost::int_min_value_t<LLONG_MIN>, boost::long_long_type>(LLONG_MIN);
test_min_max_type<boost::uint_value_t<ULLONG_MAX>, boost::ulong_long_type>(ULLONG_MAX);
#endif
#if defined(BOOST_HAS_LONG_LONG) && (defined(ULONG_LONG_MAX) && (ULONG_LONG_MAX != ULONG_MAX))
test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, boost::long_long_type>(LONG_MAX+1LL);
test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, boost::long_long_type>(LONG_MIN-1LL);
test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, boost::ulong_long_type>(ULONG_MAX+1uLL);
test_min_max_type<boost::int_max_value_t<LONG_LONG_MAX>, boost::long_long_type>(LONG_LONG_MAX);
test_min_max_type<boost::int_min_value_t<LONG_LONG_MIN>, boost::long_long_type>(LONG_LONG_MIN);
test_min_max_type<boost::uint_value_t<ULONG_LONG_MAX>, boost::ulong_long_type>(ULONG_LONG_MAX);
#endif
#if defined(BOOST_HAS_LONG_LONG) && (defined(ULONGLONG_MAX) && (ULONGLONG_MAX != ULONG_MAX))
test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, boost::long_long_type>(LONG_MAX+1LL);
test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, boost::long_long_type>(LONG_MIN-1LL);
test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, boost::ulong_long_type>(ULONG_MAX+1uLL);
test_min_max_type<boost::int_max_value_t<LONGLONG_MAX>, boost::long_long_type>(LONGLONG_MAX);
test_min_max_type<boost::int_min_value_t<LONGLONG_MIN>, boost::long_long_type>(LONGLONG_MAX);
test_min_max_type<boost::uint_value_t<ULONGLONG_MAX>, boost::ulong_long_type>(ULONGLONG_MAX);
#endif
#if defined(BOOST_HAS_LONG_LONG) && (defined(_ULLONG_MAX) && defined(_LLONG_MIN) && (_ULLONG_MAX != ULONG_MAX))
test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, boost::long_long_type>(LONG_MAX+1LL);
test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, boost::long_long_type>(LONG_MIN-1LL);
test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, boost::ulong_long_type>(ULONG_MAX+1uLL);
test_min_max_type<boost::int_max_value_t<_LLONG_MAX>, boost::long_long_type>(_LLONG_MAX);
test_min_max_type<boost::int_min_value_t<_LLONG_MIN>, boost::long_long_type>(_LLONG_MIN);
test_min_max_type<boost::uint_value_t<_ULLONG_MAX>, boost::ulong_long_type>(_ULLONG_MAX);
#endif // BOOST_HAS_LONG_LONG
#endif // BOOST_NO_INTEGRAL_INT64_T
return boost::report_errors();
}

View File

@ -0,0 +1,37 @@
// Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer_traits.hpp> // must be the only #include!
template <class T>
void check_numeric_limits_derived(const std::numeric_limits<T>&){}
template <class T>
void check()
{
typedef boost::integer_traits<T> traits;
check_numeric_limits_derived(traits());
bool b = traits::is_integral;
(void)b;
T v = traits::const_min + traits::const_max;
(void)v;
}
int main()
{
check<signed char>();
check<unsigned char>();
check<char>();
check<short>();
check<unsigned short>();
check<int>();
check<unsigned int>();
check<signed long>();
check<unsigned long>();
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
check<boost::long_long_type>();
check<boost::ulong_long_type>();
#endif
}

View File

@ -1,14 +1,9 @@
/* boost integer_traits.hpp tests
*
* Copyright Jens Maurer 2000
* Permission to use, copy, modify, sell, and distribute this software
* is hereby granted without fee provided that the above copyright notice
* appears in all copies and that both that copyright notice and this
* permission notice appear in supporting documentation,
*
* Jens Maurer makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* https://www.boost.org/LICENSE_1_0.txt)
*
* $Id$
*
@ -22,8 +17,7 @@
// use int64_t instead of long long for better portability
#include <boost/cstdint.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
#include <boost/core/lightweight_test.hpp>
/*
* General portability note:
@ -41,6 +35,7 @@ namespace fix{
inline int make_char_numeric_for_streaming(char c) { return c; }
inline int make_char_numeric_for_streaming(signed char c) { return c; }
inline int make_char_numeric_for_streaming(unsigned char c) { return c; }
inline long long int make_char_numeric_for_streaming(wchar_t c) { return c; }
}
using namespace fix;
#else
@ -48,6 +43,7 @@ template<typename T> inline T make_char_numeric_for_streaming(T x) { return x; }
inline int make_char_numeric_for_streaming(char c) { return c; }
inline int make_char_numeric_for_streaming(signed char c) { return c; }
inline int make_char_numeric_for_streaming(unsigned char c) { return c; }
inline long long int make_char_numeric_for_streaming(wchar_t c) { return c; }
#endif
template<class T>
@ -55,17 +51,25 @@ void runtest(const char * type, T)
{
typedef boost::integer_traits<T> traits;
std::cout << "Checking " << type
<< "; min is " << make_char_numeric_for_streaming(traits::min())
<< ", max is " << make_char_numeric_for_streaming(traits::max())
<< "; min is " << make_char_numeric_for_streaming((traits::min)())
<< ", max is " << make_char_numeric_for_streaming((traits::max)())
<< std::endl;
BOOST_TEST(traits::is_specialized);
#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1200)
// MSVC++ 6.0 issues a LNK1179 error (duplicate comdat) when the compiler
// generates different symbol names with a very long common prefix:
// the dummy "&& true" disambiguates between the symbols generated by this
// BOOST_TEST instantiation and the preceding one.
BOOST_TEST(traits::is_integer && true);
#else
BOOST_TEST(traits::is_integer);
BOOST_TEST(traits::is_integral);
BOOST_TEST(traits::const_min == traits::min());
BOOST_TEST(traits::const_max == traits::max());
#endif
BOOST_TEST(traits::is_integral == true);
BOOST_TEST(traits::const_min == (traits::min)());
BOOST_TEST(traits::const_max == (traits::max)());
}
int test_main(int, char*[])
int main(int, char*[])
{
runtest("bool", bool());
runtest("char", char());
@ -83,7 +87,7 @@ int test_main(int, char*[])
runtest("long", long());
typedef unsigned long unsigned_long;
runtest("unsigned long", unsigned_long());
#if !defined(BOOST_NO_INT64_T) && (!defined(BOOST_MSVC) || BOOST_MSVC > 1300) && !defined(__BORLANDC__) && !defined(__BEOS__)
#ifndef BOOST_NO_INTEGRAL_INT64_T
//
// MS/Borland compilers can't support 64-bit member constants
// BeOS doesn't have specialisations for long long in SGI's <limits> header.
@ -94,6 +98,6 @@ int test_main(int, char*[])
#endif
// Some compilers don't pay attention to std:3.6.1/5 and issue a
// warning here if "return 0;" is omitted.
return 0;
return boost::report_errors();
}

71
test/mod_inverse_test.cpp Normal file
View File

@ -0,0 +1,71 @@
/*
* (C) Copyright Nick Thompson 2018.
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
*/
#include "multiprecision_config.hpp"
#ifndef DISABLE_MP_TESTS
#include <boost/integer/mod_inverse.hpp>
#include <boost/cstdint.hpp>
#include <boost/optional/optional.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/integer/common_factor.hpp>
using boost::multiprecision::int128_t;
using boost::multiprecision::int256_t;
using boost::integer::mod_inverse;
using boost::integer::gcd;
template<class Z>
void test_mod_inverse()
{
//Z max_arg = std::numeric_limits<Z>::max();
Z max_arg = 500;
for (Z modulus = 2; modulus < max_arg; ++modulus)
{
if (modulus % 1000 == 0)
{
std::cout << "Testing all inverses modulo " << modulus << std::endl;
}
for (Z a = 1; a < modulus; ++a)
{
Z gcdam = gcd(a, modulus);
Z inv_a = mod_inverse(a, modulus);
// Should fail if gcd(a, mod) != 1:
if (gcdam > 1)
{
BOOST_TEST(inv_a == 0);
}
else
{
BOOST_TEST(inv_a > 0);
// Cast to a bigger type so the multiplication won't overflow.
int256_t a_inv = inv_a;
int256_t big_a = a;
int256_t m = modulus;
int256_t outta_be_one = (a_inv*big_a) % m;
BOOST_TEST_EQ(outta_be_one, 1);
}
}
}
}
int main()
{
test_mod_inverse<boost::int16_t>();
test_mod_inverse<boost::int32_t>();
test_mod_inverse<boost::int64_t>();
test_mod_inverse<int128_t>();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@ -0,0 +1,33 @@
// Copyright (c) 2018 Andrey Semashev
//
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_INTEGER_TEST_MULTIPRECISION_CONFIG_HPP_INCLUDED_
#define BOOST_INTEGER_TEST_MULTIPRECISION_CONFIG_HPP_INCLUDED_
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#if (defined(BOOST_MSVC) && (BOOST_MSVC < 1500)) || \
(defined(__clang_major__) && (__clang_major__ == 3) && (__clang_minor__ < 2)) || \
(defined(BOOST_GCC) && defined(BOOST_GCC_CXX11) && BOOST_GCC < 40800)
#define DISABLE_MP_TESTS
#endif
// This list of checks matches those in Boost.Multiprecision, boost/multiprecision/detail/number_base.hpp,
// as it no longer supports C++03 since 2021.
#if !defined(DISABLE_MP_TESTS) && \
(\
defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) || defined(BOOST_NO_CXX11_HDR_ARRAY) || defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)\
|| defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) || defined(BOOST_NO_CXX11_CONSTEXPR)\
|| (defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) || BOOST_WORKAROUND(__SUNPRO_CC, < 0x5140)) || defined(BOOST_NO_CXX11_REF_QUALIFIERS) || defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)\
|| defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_USER_DEFINED_LITERALS) || defined(BOOST_NO_CXX11_THREAD_LOCAL)\
|| defined(BOOST_NO_CXX11_DECLTYPE) || defined(BOOST_NO_CXX11_STATIC_ASSERT) || defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)\
|| defined(BOOST_NO_CXX11_NOEXCEPT) || defined(BOOST_NO_CXX11_REF_QUALIFIERS)\
)
#define DISABLE_MP_TESTS
#endif
#endif // BOOST_INTEGER_TEST_MULTIPRECISION_CONFIG_HPP_INCLUDED_

View File

@ -0,0 +1,14 @@
// Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer/static_log2.hpp> // must be the only #include!
int main()
{
boost::static_log2_argument_type arg = 0;
(void)arg;
boost::static_log2_result_type result = boost::static_log2<30>::value;
(void)result;
}

View File

@ -1,18 +1,16 @@
// Boost static_log2.hpp test program --------------------------------------//
// (C) Copyright Daryle Walker 2001. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// (C) Copyright Daryle Walker 2001.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for most recent version including documentation.
// See https://www.boost.org for most recent version including documentation.
// Revision History
// 01 Oct 2001 Initial version (Daryle Walker)
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp> // for main
#include <boost/core/lightweight_test.hpp> // for main
#include <boost/cstdlib.hpp> // for boost::exit_success
#include <boost/integer/static_log2.hpp> // for boost::static_log2
@ -36,7 +34,7 @@
// Main testing function
int
test_main
main
(
int , // "argc" is unused
char * [] // "argv" is unused
@ -147,5 +145,5 @@ test_main
PRIVATE_LB_TEST( 65536, 16 );
PRIVATE_LB_TEST( 65537, 16 );
return boost::exit_success;
return boost::report_errors();
}

View File

@ -0,0 +1,14 @@
// Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer/static_min_max.hpp> // must be the only #include!
int main()
{
boost::static_min_max_signed_type m = boost::static_signed_min<2, 3>::value + boost::static_signed_max<2, 3>::value;
(void)m;
boost::static_min_max_unsigned_type u = boost::static_unsigned_min<2, 3>::value + boost::static_unsigned_max<2, 3>::value;
(void)u;
}

View File

@ -1,18 +1,16 @@
// Boost static_min_max.hpp test program -----------------------------------//
// (C) Copyright Daryle Walker 2001. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// (C) Copyright Daryle Walker 2001.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for most recent version including documentation.
// See https://www.boost.org for most recent version including documentation.
// Revision History
// 23 Sep 2001 Initial version (Daryle Walker)
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp> // for main, BOOST_TEST
#include <boost/core/lightweight_test.hpp> // for main, BOOST_TEST
#include <boost/cstdlib.hpp> // for boost::exit_success
#include <boost/integer/static_min_max.hpp> // for boost::static_signed_min, etc.
@ -22,7 +20,7 @@
// Main testing function
int
test_main
main
(
int , // "argc" is unused
char * [] // "argv" is unused
@ -90,5 +88,5 @@ test_main
BOOST_TEST( (static_signed_min< -101, -101>::value) == -101 );
BOOST_TEST( (static_signed_max< -101, -101>::value) == -101 );
return boost::exit_success;
return boost::report_errors();
}