Compare commits

...

124 Commits

Author SHA1 Message Date
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
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
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
c5370a9705 Fix ambiguous 'detail' errors under msvc-8.0. 2015-01-18 20:04:09 +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
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
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
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
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
245c28d187 Merge integer documentation.
[SVN r63767]
2010-07-08 22:22:21 +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
e3da9260e1 Merge fixes from Trunk.
[SVN r62832]
2010-06-12 08:33:32 +00:00
730be18188 Merge link fix for integer.
[SVN r61060]
2010-04-05 07:41:52 +00:00
60db1676fc Merge both config and integer changes from Trunk: these are interlinked.
[SVN r58381]
2009-12-14 18:14:48 +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
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
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
3531eb1ac5 merge tests and Jamfiles for 7 libraries
[SVN r50456]
2009-01-04 05:17:02 +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
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
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
b162db6b72 Starting point for releases
[SVN r39706]
2007-10-05 14:25:06 +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
7ce7ba6bfd 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
36 changed files with 1814 additions and 1671 deletions

View File

@ -50,6 +50,11 @@ boostbook standalone
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/regex/doc/html
;
install pdf-install : standalone : <location>. <install-type>PDF ;
install pdfinstall : standalone/<format>pdf : <location>. <install-type>PDF ;
explicit pdfinstall ;
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : standalone ;
explicit boostrelease ;

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

@ -0,0 +1,258 @@
[mathpart gcd_lcm Integer Utilities (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 math
{
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 );
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/math/common_factor_rt.hpp <boost/math/common_factor_rt.hpp>]
template < typename IntegerType >
class boost::math::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::math::gcd_evaluator class template defines a function object
class to return the greatest common divisor of two integers.
The template is parameterized by a single type, called IntegerType here.
This type should be a numeric type that represents integers.
The result of the function object is always nonnegative, even if either of
the operator arguments is negative.
This function object class template is used in the corresponding version of
the GCD function template. If a numeric type wants to customize evaluations
of its greatest common divisors, then the type should specialize on the
gcd_evaluator class template.
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/math/common_factor_rt.hpp <boost/math/common_factor_rt.hpp>]
template < typename IntegerType >
class boost::math::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::math::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/math/common_factor_rt.hpp <boost/math/common_factor_rt.hpp>]
template < typename IntegerType >
constexpr IntegerType boost::math::gcd( IntegerType const &a, IntegerType const &b );
template < typename IntegerType >
constexpr IntegerType boost::math::lcm( IntegerType const &a, IntegerType const &b );
The boost::math::gcd function template returns the greatest common
(nonnegative) divisor of the two integers passed to it.
The boost::math::lcm function template returns the least common
(nonnegative) multiple of the two integers passed to it.
The function templates are parameterized on the function arguments'
IntegerType, which is also the return type. Internally, these function
templates use an object of the corresponding version of the
gcd_evaluator and lcm_evaluator class templates, respectively.
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]
[*Header: ] [@../../../../boost/math/common_factor_ct.hpp <boost/math/common_factor_ct.hpp>]
typedef ``['unspecified]`` static_gcd_type;
template < static_gcd_type Value1, static_gcd_type Value2 >
struct boost::math::static_gcd : public mpl::integral_c<static_gcd_type, implementation_defined>
{
};
template < static_gcd_type Value1, static_gcd_type Value2 >
struct boost::math::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::math::static_gcd and boost::math::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/math/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::math::gcd(6, 15) << " and "
<< boost::math::lcm(6, 15) << ", respectively."
<< endl;
cout << "The GCD and LCM of 8 and 9 are "
<< boost::math::static_gcd<8, 9>::value
<< " and "
<< boost::math::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::math::gcd_evaluator<int>() );
std::copy( c, c + 3, std::ostream_iterator<int>(cout, " ") );
}
[endsect]
[section:gcd_header Header <boost/math/common_factor.hpp>]
This header simply includes the headers
[@../../../../boost/math/common_factor_ct.hpp <boost/math/common_factor_ct.hpp>]
and [@../../../../boost/math/common_factor_rt.hpp <boost/math/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/math/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 maintainence.
[endsect]
[section:gcd_history History]
* 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]
[endmathpart]
[/
Copyright 2005, 2013 Daryle Walker.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
]

View File

@ -1,13 +1,12 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Standard Integer Types</title>
<title>Removed from library: Standard Integer Types</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
<link rel="home" href="../index.html" title="Boost.Integer">
<link rel="up" href="../index.html" title="Boost.Integer">
<link rel="prev" href="../index.html" title="Boost.Integer">
<link rel="next" href="traits.html" title="Integer Traits">
<link rel="prev" href="history.html" title="History">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@ -20,262 +19,23 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="traits.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="history.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_integer.cstdint"></a><a class="link" href="cstdint.html" title="Standard Integer Types"> Standard Integer Types</a>
<a name="boost_integer.cstdint"></a><a class="link" href="cstdint.html" title="Removed from library: Standard Integer Types">Removed from library: Standard Integer
Types</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="cstdint.html#boost_integer.cstdint.overview">Overview</a></span></dt>
<dt><span class="section"><a href="cstdint.html#boost_integer.cstdint.rationale"> Rationale</a></span></dt>
<dt><span class="section"><a href="cstdint.html#boost_integer.cstdint.ce"> <span class="emphasis"><em>Caveat emptor</em></span></a></span></dt>
<dt><span class="section"><a href="cstdint.html#boost_integer.cstdint.exact_width_integer_types">Exact-width
integer types</a></span></dt>
<dt><span class="section"><a href="cstdint.html#boost_integer.cstdint.minimum_width_integer_types">Minimum-width
integer types</a></span></dt>
<dt><span class="section"><a href="cstdint.html#boost_integer.cstdint.fastest_minimum_width_integer_types">Fastest
minimum-width integer types</a></span></dt>
<dt><span class="section"><a href="cstdint.html#boost_integer.cstdint.greatest_width_integer_types">Greatest-width
integer types</a></span></dt>
<dt><span class="section"><a href="cstdint.html#boost_integer.cstdint.integer_constant_macros">Integer
Constant Macros</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_integer.cstdint.overview"></a><a class="link" href="cstdint.html#boost_integer.cstdint.overview" title="Overview">Overview</a>
</h3></div></div></div>
<p>
The header <code class="literal"><a href="../../../../../boost/cstdint.hpp" target="_top">&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.
The <a href="../../../../../libs/config/doc/html/boost_config/cstdint.html" target="_top">Boost.Config</a>
module provides the typedefs useful for writing portable code that requires
certain integer widths.
</p>
<p>
The specifications for these types are based on the ISO/IEC 9899:1999 C Language
standard header &lt;stdint.h&gt;. The 64-bit types required by the C standard
are <span class="emphasis"><em>not required</em></span> in the boost header, and may not be
supplied for all platforms/compilers, because <code class="literal">long long</code>
is not [yet] included in the C++ standard.
</p>
<p>
See <a href="../../../test/cstdint_test.cpp" target="_top">cstdint_test.cpp</a> for
a test program.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_integer.cstdint.rationale"></a><a class="link" href="cstdint.html#boost_integer.cstdint.rationale" title="Rationale"> Rationale</a>
</h3></div></div></div>
<p>
The organization of the Boost.Integer headers and classes is designed to
take advantage of &lt;stdint.h&gt; types from the 1999 C standard without
causing undefined behavior in terms of the 1998 C++ standard. The header
&lt;boost/cstdint.hpp&gt; makes the standard integer types safely available
in namespace <code class="literal">boost</code> without placing any names in namespace
<code class="literal">std</code>. The intension is to complement rather than compete
with the C++ Standard Library. Should some future C++ standard include &lt;stdint.h&gt;
and &lt;cstdint&gt;, then &lt;boost/cstdint.hpp&gt; 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>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_integer.cstdint.ce"></a><a class="link" href="cstdint.html#boost_integer.cstdint.ce" title="Caveat emptor"> <span class="emphasis"><em>Caveat emptor</em></span></a>
</h3></div></div></div>
<p>
As an implementation artifact, certain C &lt;limits.h&gt; macro names may
possibly be visible to users of &lt;boost/cstdint.hpp&gt;. Don't use these
macros; they are not part of any Boost-specified interface. Use <code class="literal">boost::integer_traits&lt;&gt;</code>
or <code class="literal">std::numeric_limits&lt;&gt;</code> instead.
</p>
<p>
As another implementation artifact, certain C &lt;stdint.h&gt; typedef names
may possibly be visible in the global namespace to users of &lt;boost/cstdint.hpp&gt;.
Don't use these names, they are not part of any Boost-specified interface.
Use the respective names in namespace <code class="literal">boost</code> instead.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_integer.cstdint.exact_width_integer_types"></a><a class="link" href="cstdint.html#boost_integer.cstdint.exact_width_integer_types" title="Exact-width integer types">Exact-width
integer types</a>
</h3></div></div></div>
<p>
The typedef <code class="literal">int#_t</code>, with # replaced by the width, designates
a signed integer type of exactly # bits; for example <code class="literal">int8_t</code>
denotes an 8-bit signed integer type. Similarly, the typedef <code class="literal">uint#_t</code>
designates an unsigned integer type of exactly # bits.
</p>
<p>
These types are optional. However, if a platform supports integer types with
widths of 8, 16, 32, 64, or any combination thereof, then &lt;boost/cstdint.hpp&gt;
does provide the corresponding typedefs.
</p>
<p>
The absence of int64_t and uint64_t is indicated by the macro <code class="computeroutput"><span class="identifier">BOOST_NO_INT64_T</span></code>.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_integer.cstdint.minimum_width_integer_types"></a><a class="link" href="cstdint.html#boost_integer.cstdint.minimum_width_integer_types" title="Minimum-width integer types">Minimum-width
integer types</a>
</h3></div></div></div>
<p>
The typedef <code class="literal">int_least#_t</code>, with # replaced by the width,
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 class="literal">int_least32_t</code> denotes the smallest signed integer
type with a width of at least 32 bits. Similarly, the typedef name <code class="literal">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>
The following minimum-width integer types are provided for all platforms:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
<code class="literal">int_least8_t</code>
</li>
<li class="listitem">
<code class="literal">int_least16_t</code>
</li>
<li class="listitem">
<code class="literal">int_least32_t</code>
</li>
<li class="listitem">
<code class="literal">uint_least8_t</code>
</li>
<li class="listitem">
<code class="literal">uint_least16_t</code>
</li>
<li class="listitem">
<code class="literal">uint_least32_t</code>
</li>
</ul></div>
<p>
The following types are available only if, after including &lt;boost/cstdint.hpp&gt;,
the macro BOOST_NO_INT64_T is not defined:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
<code class="literal">int_least64_t</code>
</li>
<li class="listitem">
<code class="literal">uint_least64_t</code>
</li>
</ul></div>
<p>
All other minimum-width integer types are optional.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_integer.cstdint.fastest_minimum_width_integer_types"></a><a class="link" href="cstdint.html#boost_integer.cstdint.fastest_minimum_width_integer_types" title="Fastest minimum-width integer types">Fastest
minimum-width integer types</a>
</h3></div></div></div>
<p>
The typedef <code class="literal">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 class="literal">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. In any
case, however, they satisfy the signedness and width requirements.
</p>
<p>
The following fastest minimum-width integer types are provided for all platforms:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
<code class="literal">int_fast8_t</code>
</li>
<li class="listitem">
<code class="literal">int_fast16_t</code>
</li>
<li class="listitem">
<code class="literal">int_fast32_t</code>
</li>
<li class="listitem">
<code class="literal">uint_fast8_t</code>
</li>
<li class="listitem">
<code class="literal">uint_fast16_t</code>
</li>
<li class="listitem">
<code class="literal">uint_fast32_t</code>
</li>
</ul></div>
<p>
The following types are available only if, after including &lt;boost/cstdint.hpp&gt;,
the macro BOOST_NO_INT64_T is not defined:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
<code class="literal">int_fast64_t</code>
</li>
<li class="listitem">
<code class="literal">uint_fast64_t</code>
</li>
</ul></div>
<p>
All other fastest minimum-width integer types are optional.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_integer.cstdint.greatest_width_integer_types"></a><a class="link" href="cstdint.html#boost_integer.cstdint.greatest_width_integer_types" title="Greatest-width integer types">Greatest-width
integer types</a>
</h3></div></div></div>
<p>
The typedef <code class="literal">intmax_t </code>designates a signed integer type
capable of representing any value of any signed integer type.
</p>
<p>
The typedef <code class="literal">uintmax_t</code> designates an unsigned integer type
capable of representing any value of any unsigned integer type.
</p>
<p>
These types are provided for all platforms.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_integer.cstdint.integer_constant_macros"></a><a class="link" href="cstdint.html#boost_integer.cstdint.integer_constant_macros" title="Integer Constant Macros">Integer
Constant Macros</a>
</h3></div></div></div>
<p>
The following macros are always defined after inclusion of this header, these
allow integer constants of at least the specified width to be declared: INT8_C,
UINT8_C, INT16_C, UINT16_C, INT32_C, UINT32_C, INTMAX_C, UINTMAX_C.
</p>
<p>
The macros INT64_C and UINT64_C are also defined if the the macro BOOST_NO_INT64_T
is not defined.
</p>
<p>
The C99 macro __STDC_CONSTANT_MACROS is also defined as an artifact of the
implementation.
</p>
<p>
For example:
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">cstdint</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="comment">// Here the constant 0x1FFFFFFFF has the correct suffix applied:
</span><span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">uint64_t</span> <span class="identifier">c</span> <span class="special">=</span> <span class="identifier">INT64_C</span><span class="special">(</span><span class="number">0</span><span class="identifier">x1FFFFFFFF</span><span class="special">);</span>
</pre>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001 -2009 Beman Dawes, Daryle Walker, Gennaro Prota,
John Maddock<p>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001-2009 Beman
Dawes, Daryle Walker, Gennaro Prota, John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
@ -283,7 +43,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="traits.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="history.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a>
</div>
</body>
</html>

View File

@ -3,10 +3,11 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>History</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
<link rel="home" href="../index.html" title="Boost.Integer">
<link rel="up" href="../index.html" title="Boost.Integer">
<link rel="prev" href="minmax.html" title="Compile time min/max calculation">
<link rel="next" href="cstdint.html" title="Removed from library: Standard Integer Types">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@ -19,17 +20,24 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="minmax.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a>
<a accesskey="p" href="minmax.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="cstdint.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_integer.history"></a><a class="link" href="history.html" title="History"> History</a>
<a name="boost_integer.history"></a><a class="link" href="history.html" title="History">History</a>
</h2></div></div></div>
<a name="boost_integer.history.1_42_0"></a><h5>
<a name="id766183"></a>
<a class="link" href="history.html#boost_integer.history.1_42_0">1.42.0</a>
<h5>
<a name="boost_integer.history.h0"></a>
<span class="phrase"><a name="boost_integer.history.1_56_0"></a></span><a class="link" href="history.html#boost_integer.history.1_56_0">1.56.0</a>
</h5>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
Moved <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">cstdint</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code> into <a href="../../../../../libs/config/index.html" target="_top">Boost.Config</a>.
</li></ul></div>
<h5>
<a name="boost_integer.history.h1"></a>
<span class="phrase"><a name="boost_integer.history.1_42_0"></a></span><a class="link" href="history.html#boost_integer.history.1_42_0">1.42.0</a>
</h5>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
Reverted Trunk to release branch state (i.e. a "known good state").
</li>
@ -54,11 +62,11 @@
provided typedefs in new code (and update old code as soon as possible).
</li>
</ul></div>
<a name="boost_integer.history.1_32_0"></a><h5>
<a name="id766314"></a>
<a class="link" href="history.html#boost_integer.history.1_32_0">1.32.0</a>
<h5>
<a name="boost_integer.history.h2"></a>
<span class="phrase"><a name="boost_integer.history.1_32_0"></a></span><a class="link" href="history.html#boost_integer.history.1_32_0">1.32.0</a>
</h5>
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
The argument type and the result type of <code class="literal">boost::static_log2</code>
are now typedef'd. Formerly, they were hardcoded as <code class="literal">unsigned long</code>
and <code class="literal">int</code> respectively. Please, use the provided typedefs
@ -67,8 +75,8 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001 -2009 Beman Dawes, Daryle Walker, Gennaro Prota,
John Maddock<p>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001-2009 Beman
Dawes, Daryle Walker, Gennaro Prota, John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
@ -76,7 +84,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="minmax.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a>
<a accesskey="p" href="minmax.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="cstdint.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Integer Type Selection</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
<link rel="home" href="../index.html" title="Boost.Integer">
<link rel="up" href="../index.html" title="Boost.Integer">
<link rel="prev" href="traits.html" title="Integer Traits">
@ -24,13 +24,13 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_integer.integer"></a><a class="link" href="integer.html" title="Integer Type Selection"> Integer Type Selection</a>
<a name="boost_integer.integer"></a><a class="link" href="integer.html" title="Integer Type Selection">Integer Type Selection</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="integer.html#boost_integer.integer.synopsis"> Synopsis</a></span></dt>
<dt><span class="section"><a href="integer.html#boost_integer.integer.easiest"> Easiest-to-Manipulate
<dt><span class="section"><a href="integer.html#boost_integer.integer.synopsis">Synopsis</a></span></dt>
<dt><span class="section"><a href="integer.html#boost_integer.integer.easiest">Easiest-to-Manipulate
Types</a></span></dt>
<dt><span class="section"><a href="integer.html#boost_integer.integer.sized"> Sized Types</a></span></dt>
<dt><span class="section"><a href="integer.html#boost_integer.integer.sized">Sized Types</a></span></dt>
<dt><span class="section"><a href="integer.html#boost_integer.integer.example">Example</a></span></dt>
<dt><span class="section"><a href="integer.html#boost_integer.integer.demonstration_program">Demonstration
Program</a></span></dt>
@ -46,19 +46,19 @@
</p>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_integer.integer.synopsis"></a><a class="link" href="integer.html#boost_integer.integer.synopsis" title="Synopsis"> Synopsis</a>
<a name="boost_integer.integer.synopsis"></a><a class="link" href="integer.html#boost_integer.integer.synopsis" title="Synopsis">Synopsis</a>
</h3></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="comment">// fast integers from least integers
</span> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">LeastInt</span><span class="special">&gt;</span>
<span class="comment">// fast integers from least integers</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">LeastInt</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">int_fast_t</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="emphasis"><em>implementation-defined-type</em></span> <span class="identifier">type</span><span class="special">;</span>
<span class="special">};</span>
<span class="comment">// signed
</span> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">int</span> <span class="identifier">Bits</span><span class="special">&gt;</span>
<span class="comment">// signed</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">int</span> <span class="identifier">Bits</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">int_t</span>
<span class="special">{</span>
<span class="comment">/* Member exact may or may not be defined depending upon Bits */</span>
@ -67,8 +67,8 @@
<span class="keyword">typedef</span> <span class="identifier">int_fast_t</span><span class="special">&lt;</span><span class="identifier">least</span><span class="special">&gt;::</span><span class="identifier">fast</span> <span class="identifier">fast</span><span class="special">;</span>
<span class="special">};</span>
<span class="comment">// unsigned
</span> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">int</span> <span class="identifier">Bits</span><span class="special">&gt;</span>
<span class="comment">// unsigned</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">int</span> <span class="identifier">Bits</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">uint_t</span>
<span class="special">{</span>
<span class="comment">/* Member exact may or may not be defined depending upon Bits */</span>
@ -77,8 +77,8 @@
<span class="keyword">typedef</span> <span class="identifier">int_fast_t</span><span class="special">&lt;</span><span class="identifier">least</span><span class="special">&gt;::</span><span class="identifier">fast</span> <span class="identifier">fast</span><span class="special">;</span>
<span class="special">};</span>
<span class="comment">// signed
</span> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">MaxValue</span><span class="special">&gt;</span>
<span class="comment">// signed</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">MaxValue</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">int_max_value_t</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="emphasis"><em>implementation-defined-type</em></span> <span class="identifier">least</span><span class="special">;</span>
@ -92,19 +92,19 @@
<span class="keyword">typedef</span> <span class="identifier">int_fast_t</span><span class="special">&lt;</span><span class="identifier">least</span><span class="special">&gt;::</span><span class="identifier">fast</span> <span class="identifier">fast</span><span class="special">;</span>
<span class="special">};</span>
<span class="comment">// unsigned
</span> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">Value</span><span class="special">&gt;</span>
<span class="comment">// unsigned</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">Value</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">uint_value_t</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="emphasis"><em>implementation-defined-type</em></span> <span class="identifier">least</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">int_fast_t</span><span class="special">&lt;</span><span class="identifier">least</span><span class="special">&gt;::</span><span class="identifier">fast</span> <span class="identifier">fast</span><span class="special">;</span>
<span class="special">};</span>
<span class="special">}</span> <span class="comment">// namespace boost
</span></pre>
<span class="special">}</span> <span class="comment">// namespace boost</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_integer.integer.easiest"></a><a class="link" href="integer.html#boost_integer.integer.easiest" title="Easiest-to-Manipulate Types"> Easiest-to-Manipulate
<a name="boost_integer.integer.easiest"></a><a class="link" href="integer.html#boost_integer.integer.easiest" title="Easiest-to-Manipulate Types">Easiest-to-Manipulate
Types</a>
</h3></div></div></div>
<p>
@ -128,7 +128,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_integer.integer.sized"></a><a class="link" href="integer.html#boost_integer.integer.sized" title="Sized Types"> Sized Types</a>
<a name="boost_integer.integer.sized"></a><a class="link" href="integer.html#boost_integer.integer.sized" title="Sized Types">Sized Types</a>
</h3></div></div></div>
<p>
The <code class="literal">int_t</code>, <code class="literal">uint_t</code>, <code class="literal">int_max_value_t</code>,
@ -347,19 +347,19 @@
</h3></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="comment">//...
</span>
<span class="comment">//...</span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">int_t</span><span class="special">&lt;</span><span class="number">24</span><span class="special">&gt;::</span><span class="identifier">least</span> <span class="identifier">my_var</span><span class="special">;</span> <span class="comment">// my_var has at least 24-bits
</span> <span class="comment">//...
</span> <span class="comment">// This one is guarenteed not to be truncated:
</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">int_max_value_t</span><span class="special">&lt;</span><span class="number">1000</span><span class="special">&gt;::</span><span class="identifier">least</span> <span class="identifier">my1000</span> <span class="special">=</span> <span class="number">1000</span><span class="special">;</span>
<span class="comment">//...
</span> <span class="comment">// This one is guarenteed not to be truncated, and as fast
</span> <span class="comment">// to manipulate as possible, its size may be greater than
</span> <span class="comment">// that of my1000:
</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">int_max_value_t</span><span class="special">&lt;</span><span class="number">1000</span><span class="special">&gt;::</span><span class="identifier">fast</span> <span class="identifier">my_fast1000</span> <span class="special">=</span> <span class="number">1000</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">int_t</span><span class="special">&lt;</span><span class="number">24</span><span class="special">&gt;::</span><span class="identifier">least</span> <span class="identifier">my_var</span><span class="special">;</span> <span class="comment">// my_var has at least 24-bits</span>
<span class="comment">//...</span>
<span class="comment">// This one is guarenteed not to be truncated:</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">int_max_value_t</span><span class="special">&lt;</span><span class="number">1000</span><span class="special">&gt;::</span><span class="identifier">least</span> <span class="identifier">my1000</span> <span class="special">=</span> <span class="number">1000</span><span class="special">;</span>
<span class="comment">//...</span>
<span class="comment">// This one is guarenteed not to be truncated, and as fast</span>
<span class="comment">// to manipulate as possible, its size may be greater than</span>
<span class="comment">// that of my1000:</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">int_max_value_t</span><span class="special">&lt;</span><span class="number">1000</span><span class="special">&gt;::</span><span class="identifier">fast</span> <span class="identifier">my_fast1000</span> <span class="special">=</span> <span class="number">1000</span><span class="special">;</span>
<span class="special">}</span>
</pre>
</div>
@ -381,7 +381,7 @@
<p>
The rationale for the design of the templates in this header includes:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
Avoid recursion because of concern about C++'s limited guaranteed recursion
depth (17).
@ -417,8 +417,8 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001 -2009 Beman Dawes, Daryle Walker, Gennaro Prota,
John Maddock<p>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001-2009 Beman
Dawes, Daryle Walker, Gennaro Prota, John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Compile Time log2 Calculation</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
<link rel="home" href="../index.html" title="Boost.Integer">
<link rel="up" href="../index.html" title="Boost.Integer">
<link rel="prev" href="mask.html" title="Integer Masks">
@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_integer.log2"></a><a class="link" href="log2.html" title="Compile Time log2 Calculation"> Compile Time log2 Calculation</a>
<a name="boost_integer.log2"></a><a class="link" href="log2.html" title="Compile Time log2 Calculation">Compile Time log2 Calculation</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="log2.html#boost_integer.log2.synopsis">Synopsis</a></span></dt>
@ -59,12 +59,12 @@
<span class="keyword">template</span> <span class="special">&lt;</span> <span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">static_log2</span><span class="special">&lt;</span> <span class="number">0</span> <span class="special">&gt;</span>
<span class="special">{</span>
<span class="comment">// The logarithm of zero is undefined.
</span> <span class="special">};</span>
<span class="comment">// The logarithm of zero is undefined.</span>
<span class="special">};</span>
<span class="special">}</span> <span class="comment">// namespace boost
</span></pre>
<span class="special">}</span> <span class="comment">// namespace boost</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
@ -85,7 +85,7 @@
<p>
Note:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<code class="literal">static_log2_argument_type</code> is an <span class="emphasis"><em>unsigned
integer type</em></span> (C++ standard, 3.9.1p3).
@ -136,8 +136,8 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001 -2009 Beman Dawes, Daryle Walker, Gennaro Prota,
John Maddock<p>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001-2009 Beman
Dawes, Daryle Walker, Gennaro Prota, John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Integer Masks</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
<link rel="home" href="../index.html" title="Boost.Integer">
<link rel="up" href="../index.html" title="Boost.Integer">
<link rel="prev" href="integer.html" title="Integer Type Selection">
@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_integer.mask"></a><a class="link" href="mask.html" title="Integer Masks"> Integer Masks</a>
<a name="boost_integer.mask"></a><a class="link" href="mask.html" title="Integer Masks">Integer Masks</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="mask.html#boost_integer.mask.overview">Overview</a></span></dt>
@ -56,8 +56,8 @@
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_integer.mask.synopsis"></a><a class="link" href="mask.html#boost_integer.mask.synopsis" title="Synopsis">Synopsis</a>
</h3></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">cstddef</span><span class="special">&gt;</span> <span class="comment">// for std::size_t
</span>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">cstddef</span><span class="special">&gt;</span> <span class="comment">// for std::size_t</span>
<span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
@ -85,10 +85,10 @@
<span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">bit_count</span> <span class="special">=</span> <span class="identifier">Bits</span><span class="special">;</span>
<span class="special">};</span>
<span class="comment">// Specializations for low_bits_mask_t exist for certain bit counts.
</span>
<span class="special">}</span> <span class="comment">// namespace boost
</span></pre>
<span class="comment">// Specializations for low_bits_mask_t exist for certain bit counts.</span>
<span class="special">}</span> <span class="comment">// namespace boost</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
@ -105,8 +105,10 @@
of <code class="literal">high_bit_mask_t</code>.
</p>
<div class="table">
<a name="boost_integer.mask.single_bit_mask_class_template.members_of_the__boost__high_bit_mask_t__class_template"></a><p class="title"><b>Table&#160;2.&#160;Members of the `boost::high_bit_mask_t` Class Template</b></p>
<div class="table-contents"><table class="table" summary="Members of the `boost::high_bit_mask_t` Class Template">
<a name="boost_integer.mask.single_bit_mask_class_template.members_of_the__boost__high_bit_mask_t__class_template"></a><p class="title"><b>Table&#160;2.&#160;Members of the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">high_bit_mask_t</span></code>
Class Template</b></p>
<div class="table-contents"><table class="table" summary="Members of the boost::high_bit_mask_t
Class Template">
<colgroup>
<col>
<col>
@ -205,8 +207,8 @@
type. The following table describes the members of <code class="literal">low_bits_mask_t</code>.
</p>
<div class="table">
<a name="boost_integer.mask.group_bit_mask_class_template.members_of_the___boost__low_bits_mask_t__class_template"></a><p class="title"><b>Table&#160;3.&#160;Members of the [^boost::low_bits_mask_t] Class Template</b></p>
<div class="table-contents"><table class="table" summary="Members of the [^boost::low_bits_mask_t] Class Template">
<a name="boost_integer.mask.group_bit_mask_class_template.members_of_the___boost__low_bits_mask_t__class_template"></a><p class="title"><b>Table&#160;3.&#160;Members of the <code class="literal">boost::low_bits_mask_t</code> Class Template</b></p>
<div class="table-contents"><table class="table" summary="Members of the boost::low_bits_mask_t Class Template">
<colgroup>
<col>
<col>
@ -310,8 +312,8 @@
</h3></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">/</span><span class="identifier">integer_mask</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="comment">//...
</span>
<span class="comment">//...</span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">high_bit_mask_t</span><span class="special">&lt;</span><span class="number">29</span><span class="special">&gt;</span> <span class="identifier">mask1_type</span><span class="special">;</span>
@ -319,13 +321,13 @@
<span class="identifier">mask1_type</span><span class="special">::</span><span class="identifier">least</span> <span class="identifier">my_var1</span><span class="special">;</span>
<span class="identifier">mask2_type</span><span class="special">::</span><span class="identifier">fast</span> <span class="identifier">my_var2</span><span class="special">;</span>
<span class="comment">//...
</span>
<span class="comment">//...</span>
<span class="identifier">my_var1</span> <span class="special">|=</span> <span class="identifier">mask1_type</span><span class="special">::</span><span class="identifier">high_bit</span><span class="special">;</span>
<span class="identifier">my_var2</span> <span class="special">&amp;=</span> <span class="identifier">mask2_type</span><span class="special">::</span><span class="identifier">sig_bits_fast</span><span class="special">;</span>
<span class="comment">//...
</span><span class="special">}</span>
<span class="comment">//...</span>
<span class="special">}</span>
</pre>
</div>
<div class="section">
@ -363,8 +365,8 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001 -2009 Beman Dawes, Daryle Walker, Gennaro Prota,
John Maddock<p>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001-2009 Beman
Dawes, Daryle Walker, Gennaro Prota, John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Compile time min/max calculation</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
<link rel="home" href="../index.html" title="Boost.Integer">
<link rel="up" href="../index.html" title="Boost.Integer">
<link rel="prev" href="log2.html" title="Compile Time log2 Calculation">
@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_integer.minmax"></a><a class="link" href="minmax.html" title="Compile time min/max calculation"> Compile time min/max calculation</a>
<a name="boost_integer.minmax"></a><a class="link" href="minmax.html" title="Compile time min/max calculation">Compile time min/max calculation</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="minmax.html#boost_integer.minmax.synopsis">Synopsis</a></span></dt>
@ -98,18 +98,18 @@
<span class="keyword">void</span> <span class="keyword">operator</span> <span class="special">()(</span> <span class="identifier">addend1_type</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="identifier">a1</span><span class="special">,</span> <span class="identifier">addend2_type</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="identifier">a2</span><span class="special">,</span> <span class="identifier">sum_type</span> <span class="special">&amp;</span><span class="identifier">s</span> <span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="special">};</span>
<span class="comment">//...
</span>
<span class="comment">//...</span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
<span class="keyword">int</span> <span class="keyword">const</span> <span class="identifier">a1</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">0</span><span class="special">,</span> <span class="number">4</span><span class="special">,</span> <span class="number">3</span> <span class="special">};</span> <span class="comment">// 340
</span> <span class="keyword">int</span> <span class="keyword">const</span> <span class="identifier">a2</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">9</span><span class="special">,</span> <span class="number">8</span> <span class="special">};</span> <span class="comment">// 89
</span> <span class="keyword">int</span> <span class="identifier">s</span><span class="special">[</span> <span class="number">4</span> <span class="special">];</span>
<span class="keyword">int</span> <span class="keyword">const</span> <span class="identifier">a1</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">0</span><span class="special">,</span> <span class="number">4</span><span class="special">,</span> <span class="number">3</span> <span class="special">};</span> <span class="comment">// 340</span>
<span class="keyword">int</span> <span class="keyword">const</span> <span class="identifier">a2</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">9</span><span class="special">,</span> <span class="number">8</span> <span class="special">};</span> <span class="comment">// 89</span>
<span class="keyword">int</span> <span class="identifier">s</span><span class="special">[</span> <span class="number">4</span> <span class="special">];</span>
<span class="identifier">adder</span><span class="special">&lt;</span><span class="number">3</span><span class="special">,</span><span class="number">2</span><span class="special">&gt;</span> <span class="identifier">obj</span><span class="special">;</span>
<span class="identifier">obj</span><span class="special">(</span> <span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">,</span> <span class="identifier">s</span> <span class="special">);</span> <span class="comment">// 's' should be 429 or { 9, 2, 4, 0 }
</span> <span class="comment">//...
</span><span class="special">}</span>
<span class="identifier">obj</span><span class="special">(</span> <span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">,</span> <span class="identifier">s</span> <span class="special">);</span> <span class="comment">// 's' should be 429 or { 9, 2, 4, 0 }</span>
<span class="comment">//...</span>
<span class="special">}</span>
</pre>
</div>
<div class="section">
@ -145,8 +145,8 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001 -2009 Beman Dawes, Daryle Walker, Gennaro Prota,
John Maddock<p>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001-2009 Beman
Dawes, Daryle Walker, Gennaro Prota, John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -3,10 +3,10 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Integer Traits</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
<link rel="home" href="../index.html" title="Boost.Integer">
<link rel="up" href="../index.html" title="Boost.Integer">
<link rel="prev" href="cstdint.html" title="Standard Integer Types">
<link rel="prev" href="../index.html" title="Boost.Integer">
<link rel="next" href="integer.html" title="Integer Type Selection">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
@ -20,11 +20,11 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="cstdint.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="integer.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="integer.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_integer.traits"></a><a class="link" href="traits.html" title="Integer Traits"> Integer Traits</a>
<a name="boost_integer.traits"></a><a class="link" href="traits.html" title="Integer Traits">Integer Traits</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="traits.html#boost_integer.traits.motivation">Motivation</a></span></dt>
@ -45,14 +45,14 @@
<p>
For integer types, the interesting members of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;&gt;</span></code> are:
</p>
<pre class="programlisting"><span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">is_specialized</span><span class="special">;</span> <span class="comment">// Will be true for integer types.
</span><span class="keyword">static</span> <span class="identifier">T</span> <span class="identifier">min</span><span class="special">()</span> <span class="keyword">throw</span><span class="special">();</span> <span class="comment">// Smallest representable value.
</span><span class="keyword">static</span> <span class="identifier">T</span> <span class="identifier">max</span><span class="special">()</span> <span class="keyword">throw</span><span class="special">();</span> <span class="comment">// Largest representable value.
</span><span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">digits</span><span class="special">;</span> <span class="comment">// For integers, the number of value bits.
</span><span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">digits10</span><span class="special">;</span> <span class="comment">// The number of base 10 digits that can be represented.
</span><span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">is_signed</span><span class="special">;</span> <span class="comment">// True if the type is signed.
</span><span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">is_integer</span><span class="special">;</span> <span class="comment">// Will be true for all integer types.
</span></pre>
<pre class="programlisting"><span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">is_specialized</span><span class="special">;</span> <span class="comment">// Will be true for integer types.</span>
<span class="keyword">static</span> <span class="identifier">T</span> <span class="identifier">min</span><span class="special">()</span> <span class="keyword">throw</span><span class="special">();</span> <span class="comment">// Smallest representable value.</span>
<span class="keyword">static</span> <span class="identifier">T</span> <span class="identifier">max</span><span class="special">()</span> <span class="keyword">throw</span><span class="special">();</span> <span class="comment">// Largest representable value.</span>
<span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">digits</span><span class="special">;</span> <span class="comment">// For integers, the number of value bits.</span>
<span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">digits10</span><span class="special">;</span> <span class="comment">// The number of base 10 digits that can be represented.</span>
<span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">is_signed</span><span class="special">;</span> <span class="comment">// True if the type is signed.</span>
<span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">is_integer</span><span class="special">;</span> <span class="comment">// Will be true for all integer types.</span>
</pre>
<p>
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
@ -72,11 +72,11 @@
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
<span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">is_integral</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">;</span>
<span class="comment">//
</span> <span class="comment">// These members are defined only if T is a built-in
</span> <span class="comment">// integal type:
</span> <span class="comment">//
</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">const_min</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span>
<span class="comment">//</span>
<span class="comment">// These members are defined only if T is a built-in</span>
<span class="comment">// integal type:</span>
<span class="comment">//</span>
<span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">const_min</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span>
<span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">const_max</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span>
<span class="special">};</span>
<span class="special">}</span>
@ -200,8 +200,8 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001 -2009 Beman Dawes, Daryle Walker, Gennaro Prota,
John Maddock<p>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001-2009 Beman
Dawes, Daryle Walker, Gennaro Prota, John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
@ -209,7 +209,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="cstdint.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="integer.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="integer.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@ -3,9 +3,9 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Boost.Integer</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
<link rel="home" href="index.html" title="Boost.Integer">
<link rel="next" href="boost_integer/cstdint.html" title="Standard Integer Types">
<link rel="next" href="boost_integer/traits.html" title="Integer Traits">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@ -17,7 +17,7 @@
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav"><a accesskey="n" href="boost_integer/cstdint.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
<div class="spirit-nav"><a accesskey="n" href="boost_integer/traits.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
<div class="article">
<div class="titlepage">
<div>
@ -37,10 +37,10 @@
<span class="firstname">John</span> <span class="surname">Maddock</span>
</h3></div>
</div></div>
<div><p class="copyright">Copyright &#169; 2001 -2009 Beman Dawes, Daryle Walker, Gennaro Prota,
John Maddock</p></div>
<div><p class="copyright">Copyright &#169; 2001-2009 Beman
Dawes, Daryle Walker, Gennaro Prota, John Maddock</p></div>
<div><div class="legalnotice">
<a name="id759732"></a><p>
<a name="boost_integer.legal"></a><p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
@ -51,30 +51,30 @@
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="section"><a href="index.html#boost_integer.overview"> Overview</a></span></dt>
<dt><span class="section"><a href="boost_integer/cstdint.html"> Standard Integer Types</a></span></dt>
<dt><span class="section"><a href="boost_integer/traits.html"> Integer Traits</a></span></dt>
<dt><span class="section"><a href="boost_integer/integer.html"> Integer Type Selection</a></span></dt>
<dt><span class="section"><a href="boost_integer/mask.html"> Integer Masks</a></span></dt>
<dt><span class="section"><a href="boost_integer/log2.html"> Compile Time log2 Calculation</a></span></dt>
<dt><span class="section"><a href="boost_integer/minmax.html"> Compile time min/max calculation</a></span></dt>
<dt><span class="section"><a href="boost_integer/history.html"> History</a></span></dt>
<dt><span class="section"><a href="index.html#boost_integer.overview">Overview</a></span></dt>
<dt><span class="section"><a href="boost_integer/traits.html">Integer Traits</a></span></dt>
<dt><span class="section"><a href="boost_integer/integer.html">Integer Type Selection</a></span></dt>
<dt><span class="section"><a href="boost_integer/mask.html">Integer Masks</a></span></dt>
<dt><span class="section"><a href="boost_integer/log2.html">Compile Time log2 Calculation</a></span></dt>
<dt><span class="section"><a href="boost_integer/minmax.html">Compile time min/max calculation</a></span></dt>
<dt><span class="section"><a href="boost_integer/history.html">History</a></span></dt>
<dt><span class="section"><a href="boost_integer/cstdint.html">Removed from library: Standard Integer
Types</a></span></dt>
</dl>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_integer.overview"></a><a class="link" href="index.html#boost_integer.overview" title="Overview"> Overview</a>
<a name="boost_integer.overview"></a><a class="link" href="index.html#boost_integer.overview" title="Overview">Overview</a>
</h2></div></div></div>
<p>
Boost.Integer provides integer type support, particularly helpful in generic
programming. It provides standard C99 integer types, such as might be found
in &lt;stdint.h&gt;, without requiring that header. 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 <code class="computeroutput"><span class="identifier">min</span></code> and <code class="computeroutput"><span class="identifier">max</span></code>.
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.
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 <code class="computeroutput"><span class="identifier">min</span></code>
and <code class="computeroutput"><span class="identifier">max</span></code>. 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.
</p>
<div class="informaltable"><table class="table">
<colgroup>
@ -119,24 +119,6 @@
</td>
</tr>
<tr>
<td>
<p>
<a class="link" href="boost_integer/cstdint.html" title="Standard Integer Types">Standard Integer Types</a>.
</p>
</td>
<td>
<p>
<code class="literal"><a href="../../../../boost/cstdint.hpp" target="_top">&lt;boost/cstdint.hpp&gt;</a></code>
</p>
</td>
<td>
<p>
Provides typedef's based on the 1999 C Standard header <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">stdint</span><span class="special">.</span><span class="identifier">h</span><span class="special">&gt;</span></code>, wrapped in namespace boost.
This implementation may #include the compiler supplied <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">stdint</span><span class="special">.</span><span class="identifier">h</span><span class="special">&gt;</span></code>, if present.
</p>
</td>
</tr>
<tr>
<td>
<p>
<a class="link" href="boost_integer/traits.html" title="Integer Traits">Integer Traits</a>.
@ -237,10 +219,10 @@
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: July 08, 2010 at 20:45:20 GMT</small></p></td>
<td align="left"><p><small>Last revised: March 28, 2017 at 17:56:42 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
<div class="spirit-nav"><a accesskey="n" href="boost_integer/cstdint.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
<div class="spirit-nav"><a accesskey="n" href="boost_integer/traits.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
</body>
</html>

View File

@ -1,5 +1,6 @@
[article Boost.Integer
[quickbook 1.5]
[quickbook 1.6]
[compatibility-mode 1.5]
[copyright 2001-2009 Beman Dawes, Daryle Walker, Gennaro Prota, John Maddock]
[purpose Integer Type Selection]
[license
@ -15,8 +16,7 @@
[section:overview Overview]
Boost.Integer provides integer type support, particularly helpful in generic programming. It provides standard
C99 integer types, such as might be found in <stdint.h>, without requiring that header.
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`.
@ -30,12 +30,6 @@ compile-time value; and computing min and max of constant expressions.
[[^[@../../../../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.cstdint Standard Integer Types].]
[[^[@../../../../boost/cstdint.hpp <boost/cstdint.hpp>]]]
[Provides typedef's based on the 1999 C Standard header `<stdint.h>`, wrapped in namespace boost.
This implementation may #include the compiler supplied `<stdint.h>`, if present.]
]
[
[[link boost_integer.traits Integer Traits].]
[[^[@../../../../boost/integer_traits.hpp <boost/integer_traits.hpp>]]]
@ -70,146 +64,6 @@ compile-time value; and computing min and max of constant expressions.
[endsect]
[section:cstdint Standard Integer Types]
[section Overview]
The header [^[@../../../../boost/cstdint.hpp <boost/cstdint.hpp>]] provides the typedef's useful
for writing portable code that requires certain integer widths. All typedef's are in namespace boost.
The specifications for these types are based on the ISO/IEC 9899:1999 C Language standard header <stdint.h>.
The 64-bit types required by the C standard are ['not required] in the boost header,
and may not be supplied for all platforms/compilers, because [^long long] is not [yet] included in the C++ standard.
See [@../../test/cstdint_test.cpp cstdint_test.cpp] for a test program.
[endsect]
[section:rationale Rationale]
The organization of the Boost.Integer headers and classes is designed to take advantage of <stdint.h> types from the
1999 C standard without causing 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]. The intension is to complement rather than compete
with the C++ Standard Library. Should some future C++ standard include <stdint.h> and <cstdint>,
then <boost/cstdint.hpp> will continue to function, but will become redundant and may be safely deprecated.
Because these are boost headers, their names conform to boost header naming conventions rather than
C++ Standard Library header naming conventions.
[endsect]
[section:ce ['Caveat emptor]]
As an implementation artifact, certain C <limits.h> macro names may possibly be
visible to users of <boost/cstdint.hpp>. Don't use these macros; they are not part of
any Boost-specified interface. Use [^boost::integer_traits<>] or [^std::numeric_limits<>] instead.
As another implementation artifact, certain C <stdint.h> typedef names may possibly be visible
in the global namespace to users of <boost/cstdint.hpp>. Don't use these names, they are not part of
any Boost-specified interface. Use the respective names in namespace [^boost] instead.
[endsect]
[section Exact-width integer types]
The typedef [^int#_t], with # replaced by the width, designates a signed integer type of exactly # bits;
for example [^int8_t] denotes an 8-bit signed integer type. Similarly, the typedef [^uint#_t] designates an unsigned
integer type of exactly # bits.
These types are optional. However, if a platform supports integer types with widths of
8, 16, 32, 64, or any combination thereof, then <boost/cstdint.hpp> does provide the
corresponding typedefs.
The absence of int64_t and uint64_t is indicated by the macro `BOOST_NO_INT64_T`.
[endsect]
[section Minimum-width integer types]
The typedef [^int_least#_t], with # replaced by the width, 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, [^int_least32_t] denotes the smallest signed integer type with a width of at least 32 bits.
Similarly, the typedef name [^uint_least#_t] 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.
The following minimum-width integer types are provided for all platforms:
* [^int_least8_t]
* [^int_least16_t]
* [^int_least32_t]
* [^uint_least8_t]
* [^uint_least16_t]
* [^uint_least32_t]
The following types are available only if, after including <boost/cstdint.hpp>, the macro BOOST_NO_INT64_T is not defined:
* [^int_least64_t]
* [^uint_least64_t]
All other minimum-width integer types are optional.
[endsect]
[section Fastest minimum-width integer types]
The typedef [^int_fast#_t], with # replaced by the width, designates the fastest signed integer type
with a width of at least # bits. Similarly, the typedef name [^uint_fast#_t] designates the fastest
unsigned integer type with a width of at least # bits.
There is no guarantee that these types are fastest for all purposes. In any case, however, they satisfy
the signedness and width requirements.
The following fastest minimum-width integer types are provided for all platforms:
* [^int_fast8_t]
* [^int_fast16_t]
* [^int_fast32_t]
* [^uint_fast8_t]
* [^uint_fast16_t]
* [^uint_fast32_t]
The following types are available only if, after including <boost/cstdint.hpp>, the macro BOOST_NO_INT64_T is not defined:
* [^int_fast64_t]
* [^uint_fast64_t]
All other fastest minimum-width integer types are optional.
[endsect]
[section Greatest-width integer types]
The typedef [^intmax_t ]designates a signed integer type capable of representing any value of any signed integer type.
The typedef [^uintmax_t] designates an unsigned integer type capable of representing any value of any unsigned integer type.
These types are provided for all platforms.
[endsect]
[section Integer Constant Macros]
The following macros are always defined after inclusion of this header, these allow
integer constants of at least the specified width to be declared:
INT8_C, UINT8_C, INT16_C, UINT16_C, INT32_C, UINT32_C, INTMAX_C, UINTMAX_C.
The macros INT64_C and UINT64_C are also defined if the the macro BOOST_NO_INT64_T is not defined.
The C99 macro __STDC_CONSTANT_MACROS is also defined as an artifact of the implementation.
For example:
#include <boost/cstdint.hpp>
// Here the constant 0x1FFFFFFFF has the correct suffix applied:
static const boost::uint64_t c = INT64_C(0x1FFFFFFFF);
[endsect]
[endsect]
[section:traits Integer Traits]
[section Motivation]
@ -814,6 +668,11 @@ The author of the Boost compile-time extrema class templates is [@http://www.boo
[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").
@ -838,3 +697,10 @@ 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,508 +0,0 @@
// boost cstdint.hpp header file ------------------------------------------//
// (C) Copyright Beman Dawes 1999.
// (C) Copyright Jens Mauer 2001
// (C) Copyright John Maddock 2001
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/integer for 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
//
// Since we always define the INT#_C macros as per C++0x,
// define __STDC_CONSTANT_MACROS so that <stdint.h> does the right
// thing if possible, and so that the user knows that the macros
// are actually defined as per C99.
//
#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
#endif
#include <boost/config.hpp>
//
// Note that GLIBC is a bit inconsistent about whether int64_t is defined or not
// depending upon what headers happen to have been included first...
// so we disable use of stdint.h when GLIBC does not define __GLIBC_HAVE_LONG_LONG.
// See https://svn.boost.org/trac/boost/ticket/3548 and http://sources.redhat.com/bugzilla/show_bug.cgi?id=10990
//
#if defined(BOOST_HAS_STDINT_H) && (!defined(__GLIBC__) || defined(__GLIBC_HAVE_LONG_LONG))
// 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__) || defined(__IBMCPP__) || defined(_AIX)
# include <inttypes.h>
# else
# include <stdint.h>
// There is a bug in Cygwin two _C macros
# if defined(__STDC_CONSTANT_MACROS) && defined(__CYGWIN__)
# undef INTMAX_C
# undef UINTMAX_C
# define INTMAX_C(c) c##LL
# define UINTMAX_C(c) c##ULL
# endif
# endif
#ifdef __QNX__
// QNX (Dinkumware stdlib) defines these as non-standard names.
// Reflect to the standard names.
typedef ::intleast8_t int_least8_t;
typedef ::intfast8_t int_fast8_t;
typedef ::uintleast8_t uint_least8_t;
typedef ::uintfast8_t uint_fast8_t;
typedef ::intleast16_t int_least16_t;
typedef ::intfast16_t int_fast16_t;
typedef ::uintleast16_t uint_least16_t;
typedef ::uintfast16_t uint_fast16_t;
typedef ::intleast32_t int_least32_t;
typedef ::intfast32_t int_fast32_t;
typedef ::uintleast32_t uint_least32_t;
typedef ::uintfast32_t uint_fast32_t;
# ifndef BOOST_NO_INT64_T
typedef ::intleast64_t int_least64_t;
typedef ::intfast64_t int_fast64_t;
typedef ::uintleast64_t uint_least64_t;
typedef ::uintfast64_t uint_fast64_t;
# endif
#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) || defined(__osf__) || defined(__VMS)
// FreeBSD and Tru64 have 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 <boost/limits.hpp> // implementation artifact; not part of interface
# include <limits.h> // needed for limits macros
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
# if defined(__crayx1)
// The Cray X1 has a 16-bit short, however it is not recommend
// for use in performance critical code.
typedef short int16_t;
typedef short int_least16_t;
typedef int int_fast16_t;
typedef unsigned short uint16_t;
typedef unsigned short uint_least16_t;
typedef unsigned int uint_fast16_t;
# else
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;
# endif
# elif (USHRT_MAX == 0xffffffff) && defined(__MTA__)
// On MTA / XMT short is 32 bits unless the -short16 compiler flag is specified
// MTA / XMT does support the following non-standard integer types
typedef __short16 int16_t;
typedef __short16 int_least16_t;
typedef __short16 int_fast16_t;
typedef unsigned __short16 uint16_t;
typedef unsigned __short16 uint_least16_t;
typedef unsigned __short16 uint_fast16_t;
# elif (USHRT_MAX == 0xffffffff) && defined(CRAY)
// no 16-bit types on Cray:
typedef short int_least16_t;
typedef short int_fast16_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 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;
# elif (USHRT_MAX == 0xffffffff)
typedef short int32_t;
typedef short int_least32_t;
typedef short int_fast32_t;
typedef unsigned short uint32_t;
typedef unsigned short uint_least32_t;
typedef unsigned short uint_fast32_t;
# elif 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 == 0xffffffffffffffff) && defined(__MTA__)
// Integers are 64 bits on the MTA / XMT
typedef __int32 int32_t;
typedef __int32 int_least32_t;
typedef __int32 int_fast32_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int32 uint_least32_t;
typedef unsigned __int32 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 ::boost::long_long_type intmax_t;
typedef ::boost::ulong_long_type uintmax_t;
typedef ::boost::long_long_type int64_t;
typedef ::boost::long_long_type int_least64_t;
typedef ::boost::long_long_type int_fast64_t;
typedef ::boost::ulong_long_type uint64_t;
typedef ::boost::ulong_long_type uint_least64_t;
typedef ::boost::ulong_long_type 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(__GNUC__) && defined(BOOST_HAS_LONG_LONG)
__extension__ typedef long long intmax_t;
__extension__ typedef unsigned long long uintmax_t;
__extension__ typedef long long int64_t;
__extension__ typedef long long int_least64_t;
__extension__ typedef long long int_fast64_t;
__extension__ typedef unsigned long long uint64_t;
__extension__ typedef unsigned long long uint_least64_t;
__extension__ typedef unsigned long long uint_fast64_t;
# 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:
Added 23rd September 2000 (John Maddock).
Modified 11th September 2001 to be excluded when
BOOST_HAS_STDINT_H is defined (John Maddock).
Modified 11th Dec 2009 to always define the
INT#_C macros if they're not already defined (John Maddock).
******************************************************/
#if !defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && \
(!defined(INT8_C) || !defined(INT16_C) || !defined(INT32_C) || !defined(INT64_C))
//
// For the following code we get several warnings along the lines of:
//
// boost/cstdint.hpp:428:35: error: use of C99 long long integer constant
//
// So we declare this a system header to suppress these warnings.
//
#if defined(__GNUC__) && (__GNUC__ >= 4)
#pragma GCC system_header
#endif
#include <limits.h>
# define BOOST__STDC_CONSTANT_MACROS_DEFINED
# if defined(BOOST_HAS_MS_INT64)
//
// Borland/Intel/Microsoft compilers have width specific suffixes:
//
#ifndef INT8_C
# define INT8_C(value) value##i8
#endif
#ifndef INT16_C
# define INT16_C(value) value##i16
#endif
#ifndef INT32_C
# define INT32_C(value) value##i32
#endif
#ifndef INT64_C
# define INT64_C(value) value##i64
#endif
# 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
#ifndef UINT16_C
# define UINT16_C(value) value##ui16
#endif
#ifndef UINT32_C
# define UINT32_C(value) value##ui32
#endif
#ifndef UINT64_C
# define UINT64_C(value) value##ui64
#endif
#ifndef INTMAX_C
# define INTMAX_C(value) value##i64
# define UINTMAX_C(value) value##ui64
#endif
# else
// do it the old fashioned way:
// 8-bit types ------------------------------------------------------------//
# if (UCHAR_MAX == 0xff) && !defined(INT8_C)
# 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) && !defined(INT16_C)
# 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 -----------------------------------------------------------//
#ifndef INT32_C
# 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
#endif
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
#ifndef INT64_C
# if defined(BOOST_HAS_LONG_LONG) && \
(defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX) || defined(_LLONG_MAX))
# if defined(__hpux)
// HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions
# define INT64_C(value) value##LL
# define UINT64_C(value) value##uLL
# elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615ULL) || \
(defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615ULL) || \
(defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615ULL) || \
(defined(_LLONG_MAX) && _LLONG_MAX == 18446744073709551615ULL)
# define INT64_C(value) value##LL
# define UINT64_C(value) value##uLL
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
# elif ULONG_MAX != 0xffffffff
# if ULONG_MAX == 18446744073709551615U // 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
# elif defined(BOOST_HAS_LONG_LONG)
// Usual macros not defined, work things out for ourselves:
# if(~0uLL == 18446744073709551615ULL)
# define INT64_C(value) value##LL
# define UINT64_C(value) value##uLL
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# 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
# endif // Borland/Microsoft specific width suffixes
#endif // INT#_C macros.

View File

@ -20,6 +20,7 @@
#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:
@ -51,6 +52,7 @@ namespace boost
// 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 char
@ -65,14 +67,14 @@ namespace boost
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 int_least_helper<6> { typedef boost::ulong_long_type least; };
template<> struct uint_least_helper<1> { typedef boost::ulong_long_type least; };
#elif defined(BOOST_HAS_MS_INT64)
template<> struct int_least_helper<6> { typedef unsigned __int64 least; };
template<> struct uint_least_helper<1> { typedef unsigned __int64 least; };
#endif
template<> struct int_least_helper<7> { typedef unsigned long least; };
template<> struct int_least_helper<8> { typedef unsigned int least; };
template<> struct int_least_helper<9> { typedef unsigned short least; };
template<> struct int_least_helper<10> { typedef unsigned char least; };
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{};
@ -89,7 +91,8 @@ namespace boost
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
#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
@ -109,12 +112,14 @@ namespace boost
// signed
template< int Bits > // bits (including sign) required
struct int_t : public detail::exact_signed_base_helper<Bits>
struct int_t : public boost::detail::exact_signed_base_helper<Bits>
{
typedef typename detail::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
<
#ifdef BOOST_HAS_LONG_LONG
(Bits-1 <= (int)(sizeof(boost::long_long_type) * CHAR_BIT)) +
(Bits <= (int)(sizeof(boost::long_long_type) * CHAR_BIT)) +
#else
1 +
#endif
@ -128,8 +133,10 @@ namespace boost
// unsigned
template< int Bits > // bits required
struct uint_t : public detail::exact_unsigned_base_helper<Bits>
struct uint_t : public boost::detail::exact_unsigned_base_helper<Bits>
{
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(__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 =
@ -140,11 +147,10 @@ namespace boost
(Bits <= ::std::numeric_limits<unsigned char>::digits));
typedef typename detail::int_least_helper< ::boost::uint_t<Bits>::s>::least least;
#else
typedef typename detail::int_least_helper
typedef typename boost::detail::uint_least_helper
<
5 +
#ifdef BOOST_HAS_LONG_LONG
(Bits-1 <= (int)(sizeof(boost::long_long_type) * CHAR_BIT)) +
(Bits <= (int)(sizeof(boost::long_long_type) * CHAR_BIT)) +
#else
1 +
#endif
@ -161,16 +167,16 @@ namespace boost
// integer templates specifying extreme value ----------------------------//
// signed
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
#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
#endif
struct int_max_value_t
{
typedef typename detail::int_least_helper
typedef typename boost::detail::int_least_helper
<
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
#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 +
@ -183,16 +189,16 @@ namespace boost
typedef typename int_fast_t<least>::type fast;
};
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
#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
#endif
struct int_min_value_t
{
typedef typename detail::int_least_helper
typedef typename boost::detail::int_least_helper
<
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
#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 +
@ -217,7 +223,7 @@ namespace boost
// 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 =
6 +
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) +
@ -225,18 +231,17 @@ namespace boost
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 =
5 +
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::int_least_helper< ::boost::uint_value_t<MaxValue>::which>::least least;
typedef typename detail::uint_least_helper< ::boost::uint_value_t<MaxValue>::which>::least least;
#endif // BOOST_NO_INTEGRAL_INT64_T
#else
typedef typename detail::int_least_helper
typedef typename boost::detail::uint_least_helper
<
5 +
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
(MaxValue <= ::boost::integer_traits<boost::ulong_long_type>::const_max) +
#else

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
// http://www.boost.org/LICENSE_1_0.txt)
// See http://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
// http://www.boost.org/LICENSE_1_0.txt)
// See http://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 __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,465 @@
// Boost common_factor_rt.hpp header file ----------------------------------//
// (C) Copyright Daryle Walker and Paul Moore 2001-2002. 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.
// boostinspect:nolicense (don't complain about the lack of a Boost license)
// (Paul Moore hasn't been in contact for years, so there's no way to change the
// license.)
// See http://www.boost.org for updates, documentation, and revision history.
#ifndef BOOST_INTEGER_COMMON_FACTOR_RT_HPP
#define BOOST_INTEGER_COMMON_FACTOR_RT_HPP
#include <boost/integer_fwd.hpp> // self include
#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>
#ifndef BOOST_NO_CXX11_NOEXCEPT
#include <boost/type_traits/is_arithmetic.hpp>
#endif
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4127 4244) // Conditional expression is constant
#endif
namespace boost
{
namespace integer
{
#define BOOST_INT_NOEXCEPT(T) BOOST_NOEXCEPT_IF(boost::is_arithmetic<T>::value)
// Forward declarations for function templates -----------------------------//
template < typename IntegerType >
BOOST_CXX14_CONSTEXPR IntegerType gcd( IntegerType const &a, IntegerType const &b )BOOST_INT_NOEXCEPT(IntegerType);
template < typename IntegerType >
BOOST_CXX14_CONSTEXPR IntegerType lcm( IntegerType const &a, IntegerType const &b )BOOST_INT_NOEXCEPT(IntegerType);
// Greatest common divisor evaluator class declaration ---------------------//
template < typename IntegerType >
class gcd_evaluator
{
public:
// Types
typedef IntegerType result_type, first_argument_type, second_argument_type;
// Function object interface
BOOST_CXX14_CONSTEXPR result_type operator ()( first_argument_type const &a,
second_argument_type const &b )const BOOST_INT_NOEXCEPT(IntegerType) ;
}; // boost::integer::gcd_evaluator
// Least common multiple evaluator class declaration -----------------------//
template < typename IntegerType >
class lcm_evaluator
{
public:
// Types
typedef IntegerType result_type, first_argument_type, second_argument_type;
// Function object interface
BOOST_CXX14_CONSTEXPR result_type operator ()( first_argument_type const &a,
second_argument_type const &b )const BOOST_INT_NOEXCEPT(IntegerType) ;
}; // boost::integer::lcm_evaluator
// Implementation details --------------------------------------------------//
namespace detail
{
// Greatest common divisor for rings (including unsigned integers)
template < typename RingType >
BOOST_CXX14_CONSTEXPR RingType
gcd_euclidean
(
RingType a,
RingType b
)BOOST_INT_NOEXCEPT(RingType)
{
// Avoid repeated construction
#ifndef __BORLANDC__
RingType const zero = static_cast<RingType>( 0 );
#else
RingType zero = static_cast<RingType>( 0 );
#endif
// Reduce by GCD-remainder property [GCD(a,b) == GCD(b,a MOD b)]
while ( true )
{
if ( a == zero )
return b;
b %= a;
if ( b == zero )
return a;
a %= b;
}
}
// Greatest common divisor for (signed) integers
template < typename IntegerType >
inline
BOOST_CXX14_CONSTEXPR IntegerType
gcd_integer
(
IntegerType const & a,
IntegerType const & b
)BOOST_INT_NOEXCEPT(IntegerType)
{
// Avoid repeated construction
IntegerType const zero = static_cast<IntegerType>( 0 );
IntegerType const result = gcd_euclidean( a, b );
return ( result < zero ) ? static_cast<IntegerType>(-result) : result;
}
// Greatest common divisor for unsigned binary integers
template < typename BuiltInUnsigned >
BOOST_CXX14_CONSTEXPR BuiltInUnsigned
gcd_binary
(
BuiltInUnsigned u,
BuiltInUnsigned v
)BOOST_INT_NOEXCEPT(BuiltInUnsigned)
{
if ( u && v )
{
// Shift out common factors of 2
unsigned shifts = 0;
while ( !(u & 1u) && !(v & 1u) )
{
++shifts;
u >>= 1;
v >>= 1;
}
// Start with the still-even one, if any
BuiltInUnsigned r[] = { u, v };
unsigned which = static_cast<bool>( u & 1u );
// Whittle down the values via their differences
do
{
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
while ( !(r[ which ] & 1u) )
{
r[ which ] = (r[which] >> 1);
}
#else
// Remove factors of two from the even one
while ( !(r[ which ] & 1u) )
{
r[ which ] >>= 1;
}
#endif
// Replace the larger of the two with their difference
if ( r[!which] > r[which] )
{
which ^= 1u;
}
r[ which ] -= r[ !which ];
}
while ( r[which] );
// Shift-in the common factor of 2 to the residues' GCD
return r[ !which ] << shifts;
}
else
{
// At least one input is zero, return the other
// (adding since zero is the additive identity)
// or zero if both are zero.
return u + v;
}
}
// Least common multiple for rings (including unsigned integers)
template < typename RingType >
inline
BOOST_CXX14_CONSTEXPR RingType
lcm_euclidean
(
RingType const & a,
RingType const & b
)BOOST_INT_NOEXCEPT(RingType)
{
RingType const zero = static_cast<RingType>( 0 );
RingType const temp = gcd_euclidean( a, b );
return ( temp != zero ) ? ( a / temp * b ) : zero;
}
// Least common multiple for (signed) integers
template < typename IntegerType >
inline BOOST_CXX14_CONSTEXPR
IntegerType
lcm_integer
(
IntegerType const & a,
IntegerType const & b
)BOOST_INT_NOEXCEPT(IntegerType)
{
// Avoid repeated construction
IntegerType const zero = static_cast<IntegerType>( 0 );
IntegerType const result = lcm_euclidean( a, b );
return ( result < zero ) ? static_cast<IntegerType>(-result) : result;
}
// Function objects to find the best way of computing GCD or LCM
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
template < typename T, bool IsSpecialized, bool IsSigned >
struct gcd_optimal_evaluator_helper_t
{
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
{
return gcd_euclidean( a, b );
}
};
template < typename T >
struct gcd_optimal_evaluator_helper_t< T, true, true >
{
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
{
return gcd_integer( a, b );
}
};
template < typename T >
struct gcd_optimal_evaluator
{
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
{
typedef ::std::numeric_limits<T> limits_type;
typedef gcd_optimal_evaluator_helper_t<T,
limits_type::is_specialized, limits_type::is_signed> helper_type;
helper_type solver;
return solver( a, b );
}
};
#else // BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
template < typename T >
struct gcd_optimal_evaluator
{
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
{
return gcd_integer( a, b );
}
};
#endif
// Specialize for the built-in integers
#define BOOST_PRIVATE_GCD_UF( Ut ) \
template < > struct gcd_optimal_evaluator<Ut> \
{ BOOST_CXX14_CONSTEXPR Ut operator ()( Ut a, Ut b ) const BOOST_INT_NOEXCEPT(Ut) { return gcd_binary( a, b ); } }
BOOST_PRIVATE_GCD_UF( unsigned char );
BOOST_PRIVATE_GCD_UF( unsigned short );
BOOST_PRIVATE_GCD_UF( unsigned );
BOOST_PRIVATE_GCD_UF( unsigned long );
#ifdef BOOST_HAS_LONG_LONG
BOOST_PRIVATE_GCD_UF( boost::ulong_long_type );
#elif defined(BOOST_HAS_MS_INT64)
BOOST_PRIVATE_GCD_UF( unsigned __int64 );
#endif
#if CHAR_MIN == 0
BOOST_PRIVATE_GCD_UF( char ); // char is unsigned
#endif
#undef BOOST_PRIVATE_GCD_UF
#define BOOST_PRIVATE_GCD_SF( St, Ut ) \
template < > struct gcd_optimal_evaluator<St> \
{ BOOST_CXX14_CONSTEXPR St operator ()( St a, St b ) const BOOST_INT_NOEXCEPT(St) { Ut const a_abs = \
static_cast<Ut>( a < 0 ? -a : +a ), b_abs = static_cast<Ut>( \
b < 0 ? -b : +b ); return static_cast<St>( \
gcd_optimal_evaluator<Ut>()(a_abs, b_abs) ); } }
BOOST_PRIVATE_GCD_SF( signed char, unsigned char );
BOOST_PRIVATE_GCD_SF( short, unsigned short );
BOOST_PRIVATE_GCD_SF( int, unsigned );
BOOST_PRIVATE_GCD_SF( long, unsigned long );
#if CHAR_MIN < 0
BOOST_PRIVATE_GCD_SF( char, unsigned char ); // char is signed
#endif
#ifdef BOOST_HAS_LONG_LONG
BOOST_PRIVATE_GCD_SF( boost::long_long_type, boost::ulong_long_type );
#elif defined(BOOST_HAS_MS_INT64)
BOOST_PRIVATE_GCD_SF( __int64, unsigned __int64 );
#endif
#undef BOOST_PRIVATE_GCD_SF
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
template < typename T, bool IsSpecialized, bool IsSigned >
struct lcm_optimal_evaluator_helper_t
{
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
{
return lcm_euclidean( a, b );
}
};
template < typename T >
struct lcm_optimal_evaluator_helper_t< T, true, true >
{
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
{
return lcm_integer( a, b );
}
};
template < typename T >
struct lcm_optimal_evaluator
{
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
{
typedef ::std::numeric_limits<T> limits_type;
typedef lcm_optimal_evaluator_helper_t<T,
limits_type::is_specialized, limits_type::is_signed> helper_type;
helper_type solver;
return solver( a, b );
}
};
#else // BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
template < typename T >
struct lcm_optimal_evaluator
{
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
{
return lcm_integer( a, b );
}
};
#endif
// Functions to find the GCD or LCM in the best way
template < typename T >
inline BOOST_CXX14_CONSTEXPR
T
gcd_optimal
(
T const & a,
T const & b
)BOOST_INT_NOEXCEPT(T)
{
gcd_optimal_evaluator<T> solver;
return solver( a, b );
}
template < typename T >
inline BOOST_CXX14_CONSTEXPR
T
lcm_optimal
(
T const & a,
T const & b
)BOOST_INT_NOEXCEPT(T)
{
lcm_optimal_evaluator<T> solver;
return solver( a, b );
}
} // namespace detail
// Greatest common divisor evaluator member function definition ------------//
template < typename IntegerType >
inline BOOST_CXX14_CONSTEXPR
typename gcd_evaluator<IntegerType>::result_type
gcd_evaluator<IntegerType>::operator ()
(
first_argument_type const & a,
second_argument_type const & b
) const BOOST_INT_NOEXCEPT(IntegerType)
{
return detail::gcd_optimal( a, b );
}
// Least common multiple evaluator member function definition --------------//
template < typename IntegerType >
inline BOOST_CXX14_CONSTEXPR
typename lcm_evaluator<IntegerType>::result_type
lcm_evaluator<IntegerType>::operator ()
(
first_argument_type const & a,
second_argument_type const & b
) const BOOST_INT_NOEXCEPT(IntegerType)
{
return detail::lcm_optimal( a, b );
}
// Greatest common divisor and least common multiple function definitions --//
template < typename IntegerType >
inline BOOST_CXX14_CONSTEXPR
IntegerType
gcd
(
IntegerType const & a,
IntegerType const & b
) BOOST_INT_NOEXCEPT(IntegerType)
{
gcd_evaluator<IntegerType> solver;
return solver( a, b );
}
template < typename IntegerType >
inline BOOST_CXX14_CONSTEXPR
IntegerType
lcm
(
IntegerType const & a,
IntegerType const & b
) BOOST_INT_NOEXCEPT(IntegerType)
{
lcm_evaluator<IntegerType> solver;
return solver( 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,112 @@
// -----------------------------------------------------------
// 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
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// -----------------------------------------------------------
#ifndef BOOST_INTEGER_INTEGER_LOG2_HPP
#define BOOST_INTEGER_INTEGER_LOG2_HPP
#include <assert.h>
#ifdef __BORLANDC__
#include <climits>
#endif
#include <boost/limits.hpp>
#include <boost/config.hpp>
namespace boost {
namespace detail {
template <typename T>
int integer_log2_impl(T x, int n) {
int result = 0;
while (x != 1) {
const T t = static_cast<T>(x >> n);
if (t) {
result += n;
x = t;
}
n /= 2;
}
return result;
}
// helper to find the maximum power of two
// less than p (more involved than necessary,
// to avoid PTS)
//
template <int p, int n>
struct max_pow2_less {
enum { c = 2*n < p };
BOOST_STATIC_CONSTANT(int, value =
c ? (max_pow2_less< c*p, 2*c*n>::value) : n);
};
template <>
struct max_pow2_less<0, 0> {
BOOST_STATIC_CONSTANT(int, value = 0);
};
// this template is here just for Borland :(
// 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
template <typename T>
struct width {
#ifdef __BORLANDC__
BOOST_STATIC_CONSTANT(int, value = sizeof(T) * CHAR_BIT);
#else
BOOST_STATIC_CONSTANT(int, value = (std::numeric_limits<T>::digits));
#endif
};
} // detail
// ---------
// integer_log2
// ---------------
//
template <typename T>
int integer_log2(T x) {
assert(x > 0);
const int n = detail::max_pow2_less<
detail::width<T> :: value, 4
> :: value;
return detail::integer_log2_impl(x, n);
}
}
#endif // include guard

View File

@ -63,7 +63,7 @@ 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( 0u ))) << Bits )) );
BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) );
BOOST_STATIC_CONSTANT( std::size_t, bit_count = Bits );

View File

@ -158,6 +158,32 @@ template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Valu
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

@ -119,11 +119,6 @@ class integer_traits<wchar_t>
// - Mac OS X with native library
// - 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

View File

@ -0,0 +1,9 @@
#ifndef BOOST_PENDING_INTEGER_LOG2_HPP
#define BOOST_PENDING_INTEGER_LOG2_HPP
// The header file at this path is deprecated;
// use boost/integer/integer_log2.hpp instead.
#include <boost/integer/integer_log2.hpp>
#endif

12
meta/libraries.json Normal file
View File

@ -0,0 +1,12 @@
{
"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>"
]
}

View File

@ -8,18 +8,24 @@ project : requirements <warnings>all <toolset>gcc:<cxxflags>-Wextra ;
test-suite integer
:
[ run cstdint_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-long-long <toolset>darwin:<cxxflags>-Wno-long-long ]
[ run cstdint_test2.cpp : : : <toolset>gcc:<cxxflags>-Wno-long-long <toolset>darwin:<cxxflags>-Wno-long-long ]
[ 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 static_log2_test.cpp ]
[ run static_min_max_test.cpp ]
[ compile cstdint_include_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-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 ]
;

473
test/common_factor_test.cpp Normal file
View File

@ -0,0 +1,473 @@
// 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
// http://www.boost.org/LICENSE_1_0.txt)
// See http://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.Math GCD & LCM unit tests"
#include <boost/integer/common_factor.hpp>
#include <boost/config.hpp> // for BOOST_MSVC, etc.
#include <boost/detail/workaround.hpp>
#include <boost/operators.hpp>
#include <boost/core/lightweight_test.hpp>
#include <istream> // for std::basic_istream
#include <limits> // for std::numeric_limits
#include <ostream> // for std::basic_ostream
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;
} // 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
// http://support.microsoft.com/default.aspx?scid=kb;en-us;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
{
using boost::integer::gcd;
// Originally from Boost.Rational tests
BOOST_TEST_EQ( gcd<T>( 1, -1), static_cast<T>( 1) );
BOOST_TEST_EQ( gcd<T>( -1, 1), static_cast<T>( 1) );
BOOST_TEST_EQ( gcd<T>( 1, 1), static_cast<T>( 1) );
BOOST_TEST_EQ( gcd<T>( -1, -1), static_cast<T>( 1) );
BOOST_TEST_EQ( gcd<T>( 0, 0), static_cast<T>( 0) );
BOOST_TEST_EQ( gcd<T>( 7, 0), static_cast<T>( 7) );
BOOST_TEST_EQ( gcd<T>( 0, 9), static_cast<T>( 9) );
BOOST_TEST_EQ( gcd<T>( -7, 0), static_cast<T>( 7) );
BOOST_TEST_EQ( gcd<T>( 0, -9), static_cast<T>( 9) );
BOOST_TEST_EQ( gcd<T>( 42, 30), static_cast<T>( 6) );
BOOST_TEST_EQ( gcd<T>( 6, -9), static_cast<T>( 3) );
BOOST_TEST_EQ( gcd<T>(-10, -10), static_cast<T>(10) );
BOOST_TEST_EQ( gcd<T>(-25, -10), static_cast<T>( 5) );
BOOST_TEST_EQ( gcd<T>( 3, 7), static_cast<T>( 1) );
BOOST_TEST_EQ( gcd<T>( 8, 9), static_cast<T>( 1) );
BOOST_TEST_EQ( gcd<T>( 7, 49), static_cast<T>( 7) );
}
// GCD on unmarked signed integer type
void gcd_unmarked_int_test()
{
using boost::integer::gcd;
// 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(gcd<MyInt2>( 1, -1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( -1, 1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 1, 1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( -1, -1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 0, 0 )), MyInt2( 0) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 7, 0 )), MyInt2( 7) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 0, 9 )), MyInt2( 9) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( -7, 0 )), MyInt2( 7) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 0, -9 )), MyInt2( 9) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 42, 30 )), MyInt2( 6) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 6, -9 )), MyInt2( 3) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( -10, -10 )), MyInt2(10) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( -25, -10 )), MyInt2( 5) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 3, 7 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 8, 9 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 7, 49 )), MyInt2( 7) );
}
// GCD on unsigned integer types
template< class T > void gcd_unsigned_test() // unsigned_test_types
{
using boost::integer::gcd;
// Note that unmarked types (i.e. have no std::numeric_limits
// specialization) are treated like non/unsigned types
BOOST_TEST_EQ( gcd<T>( 1u, 1u), static_cast<T>( 1u) );
BOOST_TEST_EQ( gcd<T>( 0u, 0u), static_cast<T>( 0u) );
BOOST_TEST_EQ( gcd<T>( 7u, 0u), static_cast<T>( 7u) );
BOOST_TEST_EQ( gcd<T>( 0u, 9u), static_cast<T>( 9u) );
BOOST_TEST_EQ( gcd<T>(42u, 30u), static_cast<T>( 6u) );
BOOST_TEST_EQ( gcd<T>( 3u, 7u), static_cast<T>( 1u) );
BOOST_TEST_EQ( gcd<T>( 8u, 9u), static_cast<T>( 1u) );
BOOST_TEST_EQ( gcd<T>( 7u, 49u), static_cast<T>( 7u) );
}
// GCD at compile-time
void gcd_static_test()
{
using boost::integer::static_gcd;
BOOST_TEST_EQ( (static_gcd< 1, 1>::value), 1 );
BOOST_TEST_EQ( (static_gcd< 0, 0>::value), 0 );
BOOST_TEST_EQ( (static_gcd< 7, 0>::value), 7 );
BOOST_TEST_EQ( (static_gcd< 0, 9>::value), 9 );
BOOST_TEST_EQ( (static_gcd<42, 30>::value), 6 );
BOOST_TEST_EQ( (static_gcd< 3, 7>::value), 1 );
BOOST_TEST_EQ( (static_gcd< 8, 9>::value), 1 );
BOOST_TEST_EQ( (static_gcd< 7, 49>::value), 7 );
}
// TODO: non-built-in signed and unsigned integer tests, with and without
// numeric_limits specialization; polynominal tests; note any changes if
// built-ins switch to binary-GCD algorithm
// LCM tests
// LCM on signed integer types
template< class T > void lcm_int_test() // signed_test_types
{
using boost::integer::lcm;
// Originally from Boost.Rational tests
BOOST_TEST_EQ( lcm<T>( 1, -1), static_cast<T>( 1) );
BOOST_TEST_EQ( lcm<T>( -1, 1), static_cast<T>( 1) );
BOOST_TEST_EQ( lcm<T>( 1, 1), static_cast<T>( 1) );
BOOST_TEST_EQ( lcm<T>( -1, -1), static_cast<T>( 1) );
BOOST_TEST_EQ( lcm<T>( 0, 0), static_cast<T>( 0) );
BOOST_TEST_EQ( lcm<T>( 6, 0), static_cast<T>( 0) );
BOOST_TEST_EQ( lcm<T>( 0, 7), static_cast<T>( 0) );
BOOST_TEST_EQ( lcm<T>( -5, 0), static_cast<T>( 0) );
BOOST_TEST_EQ( lcm<T>( 0, -4), static_cast<T>( 0) );
BOOST_TEST_EQ( lcm<T>( 18, 30), static_cast<T>(90) );
BOOST_TEST_EQ( lcm<T>( -6, 9), static_cast<T>(18) );
BOOST_TEST_EQ( lcm<T>(-10, -10), static_cast<T>(10) );
BOOST_TEST_EQ( lcm<T>( 25, -10), static_cast<T>(50) );
BOOST_TEST_EQ( lcm<T>( 3, 7), static_cast<T>(21) );
BOOST_TEST_EQ( lcm<T>( 8, 9), static_cast<T>(72) );
BOOST_TEST_EQ( lcm<T>( 7, 49), static_cast<T>(49) );
}
// LCM on unmarked signed integer type
void lcm_unmarked_int_test()
{
using boost::integer::lcm;
// 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(lcm<MyInt2>( 1, -1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( -1, 1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 1, 1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( -1, -1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 0, 0 )), MyInt2( 0) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 6, 0 )), MyInt2( 0) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 0, 7 )), MyInt2( 0) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( -5, 0 )), MyInt2( 0) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 0, -4 )), MyInt2( 0) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 18, 30 )), MyInt2(90) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( -6, 9 )), MyInt2(18) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( -10, -10 )), MyInt2(10) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 25, -10 )), MyInt2(50) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 3, 7 )), MyInt2(21) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 8, 9 )), MyInt2(72) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 7, 49 )), MyInt2(49) );
}
// LCM on unsigned integer types
template< class T > void lcm_unsigned_test() // unsigned_test_types
{
using boost::integer::lcm;
// Note that unmarked types (i.e. have no std::numeric_limits
// specialization) are treated like non/unsigned types
BOOST_TEST_EQ( lcm<T>( 1u, 1u), static_cast<T>( 1u) );
BOOST_TEST_EQ( lcm<T>( 0u, 0u), static_cast<T>( 0u) );
BOOST_TEST_EQ( lcm<T>( 6u, 0u), static_cast<T>( 0u) );
BOOST_TEST_EQ( lcm<T>( 0u, 7u), static_cast<T>( 0u) );
BOOST_TEST_EQ( lcm<T>(18u, 30u), static_cast<T>(90u) );
BOOST_TEST_EQ( lcm<T>( 3u, 7u), static_cast<T>(21u) );
BOOST_TEST_EQ( lcm<T>( 8u, 9u), static_cast<T>(72u) );
BOOST_TEST_EQ( lcm<T>( 7u, 49u), static_cast<T>(49u) );
}
// LCM at compile-time
void lcm_static_test()
{
using boost::integer::static_lcm;
BOOST_TEST_EQ( (static_lcm< 1, 1>::value), 1 );
BOOST_TEST_EQ( (static_lcm< 0, 0>::value), 0 );
BOOST_TEST_EQ( (static_lcm< 6, 0>::value), 0 );
BOOST_TEST_EQ( (static_lcm< 0, 7>::value), 0 );
BOOST_TEST_EQ( (static_lcm<18, 30>::value), 90 );
BOOST_TEST_EQ( (static_lcm< 3, 7>::value), 21 );
BOOST_TEST_EQ( (static_lcm< 8, 9>::value), 72 );
BOOST_TEST_EQ( (static_lcm< 7, 49>::value), 49 );
}
// TODO: see GCD to-do
// main
// Various types to test with each GCD/LCM
#define TEST_SIGNED_( test ) \
test<signed char>(); \
test<short>(); \
test<int>(); \
test<long>(); \
test<MyInt1>();
#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
#define TEST_UNSIGNED_( test ) \
test<unsigned char>(); \
test<unsigned short>(); \
test<unsigned>(); \
test<unsigned long>(); \
test<MyUnsigned1>(); \
test<MyUnsigned2>();
#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
int main()
{
TEST_SIGNED( gcd_int_test )
gcd_unmarked_int_test();
TEST_UNSIGNED( gcd_unsigned_test )
gcd_static_test();
TEST_SIGNED( lcm_int_test )
lcm_unmarked_int_test();
TEST_UNSIGNED( lcm_unsigned_test )
lcm_static_test();
return boost::report_errors();
}

View File

@ -1,69 +0,0 @@
// Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define __STDC_CONSTANT_MACROS
#include <boost/cstdint.hpp> // must be the only #include!
int main()
{
boost::int8_t i8 = INT8_C(0);
(void)i8;
boost::uint8_t ui8 = UINT8_C(0);
(void)ui8;
boost::int16_t i16 = INT16_C(0);
(void)i16;
boost::uint16_t ui16 = UINT16_C(0);
(void)ui16;
boost::int32_t i32 = INT32_C(0);
(void)i32;
boost::uint32_t ui32 = UINT32_C(0);
(void)ui32;
#ifndef BOOST_NO_INT64_T
boost::int64_t i64 = 0;
(void)i64;
boost::uint64_t ui64 = 0;
(void)ui64;
#endif
boost::int_least8_t i8least = INT8_C(0);
(void)i8least;
boost::uint_least8_t ui8least = UINT8_C(0);
(void)ui8least;
boost::int_least16_t i16least = INT16_C(0);
(void)i16least;
boost::uint_least16_t ui16least = UINT16_C(0);
(void)ui16least;
boost::int_least32_t i32least = INT32_C(0);
(void)i32least;
boost::uint_least32_t ui32least = UINT32_C(0);
(void)ui32least;
#ifndef BOOST_NO_INT64_T
boost::int_least64_t i64least = 0;
(void)i64least;
boost::uint_least64_t ui64least = 0;
(void)ui64least;
#endif
boost::int_fast8_t i8fast = INT8_C(0);
(void)i8fast;
boost::uint_fast8_t ui8fast = UINT8_C(0);
(void)ui8fast;
boost::int_fast16_t i16fast = INT16_C(0);
(void)i16fast;
boost::uint_fast16_t ui16fast = UINT16_C(0);
(void)ui16fast;
boost::int_fast32_t i32fast = INT32_C(0);
(void)i32fast;
boost::uint_fast32_t ui32fast = UINT32_C(0);
(void)ui32fast;
#ifndef BOOST_NO_INT64_T
boost::int_fast64_t i64fast = 0;
(void)i64fast;
boost::uint_fast64_t ui64fast = 0;
(void)ui64fast;
#endif
boost::intmax_t im = 0;
(void)im;
boost::uintmax_t uim = 0;
(void)uim;
}

View File

@ -1,238 +0,0 @@
// boost cstdint.hpp test program ------------------------------------------//
// Copyright Beman Dawes 2000. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/integer for 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
//
// There are two ways to test this: in version 1, we include cstdint.hpp as the first
// include, which means we get decide whether __STDC_CONSTANT_MACROS is defined.
// In version two we include stdint.h with __STDC_CONSTANT_MACROS *NOT* defined first,
// and check that we still end up with compatible definitions for the INT#_C macros.
//
// This is version 1.
//
#if defined(__GNUC__) && (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4))
// We can't suppress this warning on the command line as not all GCC versions support -Wno-type-limits :
#pragma GCC diagnostic ignored "-Wtype-limits"
#endif
#include <boost/cstdint.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <iostream>
#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()
{
BOOST_TEST( int8 == -127 );
BOOST_TEST( int_least8 == -127 );
BOOST_TEST( int_fast8 == -127 );
BOOST_TEST( uint8 == 255u );
BOOST_TEST( uint_least8 == 255u );
BOOST_TEST( uint_fast8 == 255u );
BOOST_TEST( int16 == -32767 );
BOOST_TEST( int_least16 == -32767 );
BOOST_TEST( int_fast16 == -32767 );
BOOST_TEST( uint16 == 65535u );
BOOST_TEST( uint_least16 == 65535u );
BOOST_TEST( uint_fast16 == 65535u );
BOOST_TEST( int32 == -2147483647 );
BOOST_TEST( int_least32 == -2147483647 );
BOOST_TEST( int_fast32 == -2147483647 );
BOOST_TEST( uint32 == 4294967295u );
BOOST_TEST( uint_least32 == 4294967295u );
BOOST_TEST( 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:
BOOST_TEST(sizeof(T1) <= sizeof(T2));
#else
BOOST_TEST(sizeof(T1) == sizeof(T2));
BOOST_TEST(t1 == t2);
#endif
#if defined(BOOST_HAS_STDINT_H)
// native headers are permitted to promote small
// unsigned types to type int:
if(sizeof(T1) >= sizeof(int))
{
if(t1 > 0)
BOOST_TEST(t2 > 0);
else
BOOST_TEST(!(t2 > 0));
}
else if(t1 < 0)
BOOST_TEST(!(t2 > 0));
#else
if(t1 > 0)
BOOST_TEST(t2 > 0);
else
BOOST_TEST(!(t2 > 0));
#endif
}
int main(int, char*[])
{
#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
BOOST_TEST( int8 == -127 );
BOOST_TEST( int_least8 == -127 );
BOOST_TEST( int_fast8 == -127 );
BOOST_TEST( uint8 == 255u );
BOOST_TEST( uint_least8 == 255u );
BOOST_TEST( uint_fast8 == 255u );
BOOST_TEST( int16 == -32767 );
BOOST_TEST( int_least16 == -32767 );
BOOST_TEST( int_fast16 == -32767 );
BOOST_TEST( uint16 == 65535u );
BOOST_TEST( uint_least16 == 65535u );
BOOST_TEST( uint_fast16 == 65535u );
BOOST_TEST( int32 == -2147483647 );
BOOST_TEST( int_least32 == -2147483647 );
BOOST_TEST( int_fast32 == -2147483647 );
BOOST_TEST( uint32 == 4294967295u );
BOOST_TEST( uint_least32 == 4294967295u );
BOOST_TEST( uint_fast32 == 4294967295u );
#ifndef BOOST_NO_INT64_T
BOOST_TEST( int64 == INT64_C(-9223372036854775807) );
BOOST_TEST( int_least64 == INT64_C(-9223372036854775807) );
BOOST_TEST( int_fast64 == INT64_C(-9223372036854775807) );
BOOST_TEST( uint64 == UINT64_C(18446744073709551615) );
BOOST_TEST( uint_least64 == UINT64_C(18446744073709551615) );
BOOST_TEST( uint_fast64 == UINT64_C(18446744073709551615) );
BOOST_TEST( intmax == INT64_C(-9223372036854775807) );
BOOST_TEST( uintmax == UINT64_C(18446744073709551615) );
#else
BOOST_TEST( intmax == -2147483647 );
BOOST_TEST( uintmax == 4294967295u );
#endif
std::cout << "OK\n";
return boost::report_errors();
}

View File

@ -1,248 +0,0 @@
// boost cstdint.hpp test program ------------------------------------------//
// Copyright Beman Dawes 2000. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/integer for 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
//
// There are two ways to test this: in version 1, we include cstdint.hpp as the first
// include, which means we get decide whether __STDC_CONSTANT_MACROS is defined.
// In version two we include stdint.h with __STDC_CONSTANT_MACROS *NOT* defined first,
// and check that we still end up with compatible definitions for the INT#_C macros.
//
// This is version 2.
//
#if defined(__GNUC__) && (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4))
// We can't suppress this warning on the command line as not all GCC versions support -Wno-type-limits :
#pragma GCC diagnostic ignored "-Wtype-limits"
#endif
#include <boost/config.hpp>
#ifdef BOOST_HAS_STDINT_H
#ifdef __hpux
# include <inttypes.h>
#else
# include <stdint.h>
#endif
#endif
#include <boost/cstdint.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <iostream>
#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()
{
BOOST_TEST( int8 == -127 );
BOOST_TEST( int_least8 == -127 );
BOOST_TEST( int_fast8 == -127 );
BOOST_TEST( uint8 == 255u );
BOOST_TEST( uint_least8 == 255u );
BOOST_TEST( uint_fast8 == 255u );
BOOST_TEST( int16 == -32767 );
BOOST_TEST( int_least16 == -32767 );
BOOST_TEST( int_fast16 == -32767 );
BOOST_TEST( uint16 == 65535u );
BOOST_TEST( uint_least16 == 65535u );
BOOST_TEST( uint_fast16 == 65535u );
BOOST_TEST( int32 == -2147483647 );
BOOST_TEST( int_least32 == -2147483647 );
BOOST_TEST( int_fast32 == -2147483647 );
BOOST_TEST( uint32 == 4294967295u );
BOOST_TEST( uint_least32 == 4294967295u );
BOOST_TEST( 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:
BOOST_TEST(sizeof(T1) <= sizeof(T2));
#else
BOOST_TEST(sizeof(T1) == sizeof(T2));
BOOST_TEST(t1 == t2);
#endif
#if defined(BOOST_HAS_STDINT_H)
// native headers are permitted to promote small
// unsigned types to type int:
if(sizeof(T1) >= sizeof(int))
{
if(t1 > 0)
BOOST_TEST(t2 > 0);
else
BOOST_TEST(!(t2 > 0));
}
else if(t1 < 0)
BOOST_TEST(!(t2 > 0));
#else
if(t1 > 0)
BOOST_TEST(t2 > 0);
else
BOOST_TEST(!(t2 > 0));
#endif
}
int main(int, char*[])
{
#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
BOOST_TEST( int8 == -127 );
BOOST_TEST( int_least8 == -127 );
BOOST_TEST( int_fast8 == -127 );
BOOST_TEST( uint8 == 255u );
BOOST_TEST( uint_least8 == 255u );
BOOST_TEST( uint_fast8 == 255u );
BOOST_TEST( int16 == -32767 );
BOOST_TEST( int_least16 == -32767 );
BOOST_TEST( int_fast16 == -32767 );
BOOST_TEST( uint16 == 65535u );
BOOST_TEST( uint_least16 == 65535u );
BOOST_TEST( uint_fast16 == 65535u );
BOOST_TEST( int32 == -2147483647 );
BOOST_TEST( int_least32 == -2147483647 );
BOOST_TEST( int_fast32 == -2147483647 );
BOOST_TEST( uint32 == 4294967295u );
BOOST_TEST( uint_least32 == 4294967295u );
BOOST_TEST( uint_fast32 == 4294967295u );
#ifndef BOOST_NO_INT64_T
BOOST_TEST( int64 == INT64_C(-9223372036854775807) );
BOOST_TEST( int_least64 == INT64_C(-9223372036854775807) );
BOOST_TEST( int_fast64 == INT64_C(-9223372036854775807) );
BOOST_TEST( uint64 == UINT64_C(18446744073709551615) );
BOOST_TEST( uint_least64 == UINT64_C(18446744073709551615) );
BOOST_TEST( uint_fast64 == UINT64_C(18446744073709551615) );
BOOST_TEST( intmax == INT64_C(-9223372036854775807) );
BOOST_TEST( uintmax == UINT64_C(18446744073709551615) );
#else
BOOST_TEST( intmax == -2147483647 );
BOOST_TEST( uintmax == 4294967295u );
#endif
std::cout << "OK\n";
return boost::report_errors();
}

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 http://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 http://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 http://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 http://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 http://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 http://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 http://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,42 @@
// (C) Copyright John Maddock 2017.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer/common_factor.hpp>
#ifndef BOOST_NO_CXX14_CONSTEXPR
void test_constexpr()
{
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 found in constexpr gcd.");
static_assert(l == 6268802158037, "Expected result not found in constexpr lcm.");
}
#endif
#ifndef BOOST_NO_CXX11_NOEXCEPT
void test_noexcept()
{
static_assert(noexcept(boost::integer::gcd(static_cast<unsigned char>(2), static_cast<unsigned char>(4))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<char>(2), static_cast<char>(4))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<signed char>(2), static_cast<signed char>(4))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<short>(2), static_cast<short>(4))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<unsigned short>(2), static_cast<unsigned short>(4))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<int>(2), static_cast<int>(4))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<unsigned int>(2), static_cast<unsigned int>(4))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<long>(2), static_cast<long>(4))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<unsigned long>(2), static_cast<unsigned long>(4))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<long long>(2), static_cast<long long>(4))), "Expected a noexcept function.");
static_assert(noexcept(boost::integer::gcd(static_cast<unsigned long long>(2), static_cast<unsigned long long>(4))), "Expected a noexcept function.");
}
#endif

View File

@ -18,6 +18,7 @@
#include <boost/detail/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)
@ -152,7 +153,7 @@ void do_test_bits()
if(boost::detail::test_errors() != last_error_count)
{
last_error_count = boost::detail::test_errors();
std::cout << "Errors occured while testing with bit count = " << Bits << std::endl;
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;