Squashed 'third_party/boostorg/integer/' content from commit 66dbc2c
Change-Id: I7c6c0492e5492b9349522c6e7be10f459adf4249
git-subtree-dir: third_party/boostorg/integer
git-subtree-split: 66dbc2c70aecc47d5a711b5dac6da6237721a644
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..3e84d7c
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,96 @@
+* text=auto !eol svneol=native#text/plain
+*.gitattributes text svneol=native#text/plain
+
+# Scriptish formats
+*.bat text svneol=native#text/plain
+*.bsh text svneol=native#text/x-beanshell
+*.cgi text svneol=native#text/plain
+*.cmd text svneol=native#text/plain
+*.js text svneol=native#text/javascript
+*.php text svneol=native#text/x-php
+*.pl text svneol=native#text/x-perl
+*.pm text svneol=native#text/x-perl
+*.py text svneol=native#text/x-python
+*.sh eol=lf svneol=LF#text/x-sh
+configure eol=lf svneol=LF#text/x-sh
+
+# Image formats
+*.bmp binary svneol=unset#image/bmp
+*.gif binary svneol=unset#image/gif
+*.ico binary svneol=unset#image/ico
+*.jpeg binary svneol=unset#image/jpeg
+*.jpg binary svneol=unset#image/jpeg
+*.png binary svneol=unset#image/png
+*.tif binary svneol=unset#image/tiff
+*.tiff binary svneol=unset#image/tiff
+*.svg text svneol=native#image/svg%2Bxml
+
+# Data formats
+*.pdf binary svneol=unset#application/pdf
+*.avi binary svneol=unset#video/avi
+*.doc binary svneol=unset#application/msword
+*.dsp text svneol=crlf#text/plain
+*.dsw text svneol=crlf#text/plain
+*.eps binary svneol=unset#application/postscript
+*.gz binary svneol=unset#application/gzip
+*.mov binary svneol=unset#video/quicktime
+*.mp3 binary svneol=unset#audio/mpeg
+*.ppt binary svneol=unset#application/vnd.ms-powerpoint
+*.ps binary svneol=unset#application/postscript
+*.psd binary svneol=unset#application/photoshop
+*.rdf binary svneol=unset#text/rdf
+*.rss text svneol=unset#text/xml
+*.rtf binary svneol=unset#text/rtf
+*.sln text svneol=native#text/plain
+*.swf binary svneol=unset#application/x-shockwave-flash
+*.tgz binary svneol=unset#application/gzip
+*.vcproj text svneol=native#text/xml
+*.vcxproj text svneol=native#text/xml
+*.vsprops text svneol=native#text/xml
+*.wav binary svneol=unset#audio/wav
+*.xls binary svneol=unset#application/vnd.ms-excel
+*.zip binary svneol=unset#application/zip
+
+# Text formats
+.htaccess text svneol=native#text/plain
+*.bbk text svneol=native#text/xml
+*.cmake text svneol=native#text/plain
+*.css text svneol=native#text/css
+*.dtd text svneol=native#text/xml
+*.htm text svneol=native#text/html
+*.html text svneol=native#text/html
+*.ini text svneol=native#text/plain
+*.log text svneol=native#text/plain
+*.mak text svneol=native#text/plain
+*.qbk text svneol=native#text/plain
+*.rst text svneol=native#text/plain
+*.sql text svneol=native#text/x-sql
+*.txt text svneol=native#text/plain
+*.xhtml text svneol=native#text/xhtml%2Bxml
+*.xml text svneol=native#text/xml
+*.xsd text svneol=native#text/xml
+*.xsl text svneol=native#text/xml
+*.xslt text svneol=native#text/xml
+*.xul text svneol=native#text/xul
+*.yml text svneol=native#text/plain
+boost-no-inspect text svneol=native#text/plain
+CHANGES text svneol=native#text/plain
+COPYING text svneol=native#text/plain
+INSTALL text svneol=native#text/plain
+Jamfile text svneol=native#text/plain
+Jamroot text svneol=native#text/plain
+Jamfile.v2 text svneol=native#text/plain
+Jamrules text svneol=native#text/plain
+Makefile* text svneol=native#text/plain
+README text svneol=native#text/plain
+TODO text svneol=native#text/plain
+
+# Code formats
+*.c text svneol=native#text/plain
+*.cpp text svneol=native#text/plain
+*.h text svneol=native#text/plain
+*.hpp text svneol=native#text/plain
+*.ipp text svneol=native#text/plain
+*.tpp text svneol=native#text/plain
+*.jam text svneol=native#text/plain
+*.java text svneol=native#text/plain
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..f73f33d
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,348 @@
+# Copyright 2016, 2017 Peter Dimov
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
+
+language: cpp
+
+sudo: false
+
+python: "2.7"
+
+os:
+ - linux
+ - osx
+
+branches:
+ only:
+ - master
+ - develop
+
+env:
+ matrix:
+ - BOGUS_JOB=true
+
+matrix:
+
+ exclude:
+ - env: BOGUS_JOB=true
+
+ include:
+ - os: linux
+ env: TOOLSET=gcc COMPILER=g++ CXXSTD=c++03
+
+ - os: linux
+ env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=c++03
+ addons:
+ apt:
+ packages:
+ - g++-4.7
+ sources:
+ - ubuntu-toolchain-r-test
+
+ - os: linux
+ env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=c++11
+ addons:
+ apt:
+ packages:
+ - g++-4.7
+ sources:
+ - ubuntu-toolchain-r-test
+
+ - os: linux
+ env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=c++03
+ addons:
+ apt:
+ packages:
+ - g++-4.8
+ sources:
+ - ubuntu-toolchain-r-test
+
+ - os: linux
+ env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=c++11
+ addons:
+ apt:
+ packages:
+ - g++-4.8
+ sources:
+ - ubuntu-toolchain-r-test
+
+ - os: linux
+ env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++03
+ addons:
+ apt:
+ packages:
+ - g++-4.9
+ sources:
+ - ubuntu-toolchain-r-test
+
+ - os: linux
+ env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++11
+ addons:
+ apt:
+ packages:
+ - g++-4.9
+ sources:
+ - ubuntu-toolchain-r-test
+
+ - os: linux
+ env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++03
+ addons:
+ apt:
+ packages:
+ - g++-5
+ sources:
+ - ubuntu-toolchain-r-test
+
+ - os: linux
+ env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++11
+ addons:
+ apt:
+ packages:
+ - g++-5
+ sources:
+ - ubuntu-toolchain-r-test
+
+ - os: linux
+ env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++14
+ addons:
+ apt:
+ packages:
+ - g++-5
+ sources:
+ - ubuntu-toolchain-r-test
+
+ - os: linux
+ env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++03
+ addons:
+ apt:
+ packages:
+ - g++-6
+ sources:
+ - ubuntu-toolchain-r-test
+
+ - os: linux
+ env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++11
+ addons:
+ apt:
+ packages:
+ - g++-6
+ sources:
+ - ubuntu-toolchain-r-test
+
+ - os: linux
+ env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++14
+ addons:
+ apt:
+ packages:
+ - g++-6
+ sources:
+ - ubuntu-toolchain-r-test
+
+ - os: linux
+ env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++1z
+ addons:
+ apt:
+ packages:
+ - g++-6
+ sources:
+ - ubuntu-toolchain-r-test
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++03
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=c++03
+ addons:
+ apt:
+ packages:
+ - clang-3.5
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.5
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=c++11
+ addons:
+ apt:
+ packages:
+ - clang-3.5
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.5
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++03
+ addons:
+ apt:
+ packages:
+ - clang-3.6
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.6
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++11
+ addons:
+ apt:
+ packages:
+ - clang-3.6
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.6
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++03
+ addons:
+ apt:
+ packages:
+ - clang-3.7
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.7
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++11
+ addons:
+ apt:
+ packages:
+ - clang-3.7
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.7
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++03
+ addons:
+ apt:
+ packages:
+ - clang-3.8
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.8
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++11
+ addons:
+ apt:
+ packages:
+ - clang-3.8
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.8
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++14
+ addons:
+ apt:
+ packages:
+ - clang-3.8
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.8
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++1z
+ addons:
+ apt:
+ packages:
+ - clang-3.8
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.8
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++03
+ addons:
+ apt:
+ packages:
+ - clang-3.9
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.9
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++11
+ addons:
+ apt:
+ packages:
+ - clang-3.9
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.9
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++14
+ addons:
+ apt:
+ packages:
+ - clang-3.9
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.9
+
+ - os: linux
+ env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++1z
+ addons:
+ apt:
+ packages:
+ - clang-3.9
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.9
+
+ - os: osx
+ env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++03
+
+ - os: osx
+ env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11
+
+ - os: osx
+ env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++14
+
+ - os: osx
+ env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++1z
+
+install:
+ - cd ..
+ - git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
+ - cd boost-root
+ - git submodule update --init tools/build
+ - git submodule update --init libs/config
+ - git submodule update --init libs/core
+ - git submodule update --init libs/detail
+ - git submodule update --init libs/assert
+ - git submodule update --init libs/static_assert
+ - git submodule update --init libs/type_traits
+ - git submodule update --init libs/mpl
+ - git submodule update --init libs/preprocessor
+ - git submodule update --init libs/multiprecision
+ - git submodule update --init libs/math
+ - git submodule update --init libs/rational
+ - git submodule update --init libs/throw_exception
+ - git submodule update --init libs/predef
+ - git submodule update --init libs/lexical_cast
+ - git submodule update --init libs/range
+ - git submodule update --init libs/iterator
+ - git submodule update --init libs/concept_check
+ - git submodule update --init libs/numeric
+ - git submodule update --init libs/array
+ - git submodule update --init libs/container
+ - git submodule update --init libs/move
+ - git submodule update --init libs/functional
+ - git submodule update --init libs/random
+ - git submodule update --init libs/utility
+ - cp -r $TRAVIS_BUILD_DIR/* libs/integer
+ - ./bootstrap.sh
+ - ./b2 headers
+
+script:
+ - |-
+ echo "using $TOOLSET : : $COMPILER : <cxxflags>-std=$CXXSTD ;" > ~/user-config.jam
+ - ./b2 libs/integer/test toolset=$TOOLSET
+
+notifications:
+ email:
+ on_success: always
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..956073a
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,83 @@
+# Copyright 2016 Peter Dimov
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
+
+version: 1.0.{build}-{branch}
+
+shallow_clone: true
+
+branches:
+ only:
+ - master
+ - develop
+
+platform:
+ - x64
+
+environment:
+ matrix:
+ - ARGS: --toolset=msvc-9.0 address-model=32
+ - ARGS: --toolset=msvc-10.0 address-model=32
+ - ARGS: --toolset=msvc-11.0 address-model=32
+ - ARGS: --toolset=msvc-12.0 address-model=32
+ - ARGS: --toolset=msvc-14.0 address-model=32
+ - ARGS: --toolset=msvc-12.0 address-model=64
+ - ARGS: --toolset=msvc-14.0 address-model=64
+ - ARGS: --toolset=msvc-14.0 address-model=64 cxxflags=-std:c++latest
+ - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
+ ARGS: --toolset=msvc-14.1 address-model=64
+ - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
+ ARGS: --toolset=msvc-14.1 address-model=32
+ - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
+ ARGS: --toolset=msvc-14.1 address-model=64 cxxflags=-std:c++latest
+ - ARGS: --toolset=gcc address-model=64
+ PATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%
+ - ARGS: --toolset=gcc address-model=64 cxxflags=-std=gnu++1z
+ PATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%
+ - ARGS: --toolset=gcc address-model=32
+ PATH: C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin;%PATH%
+ - ARGS: --toolset=gcc address-model=32 linkflags=-Wl,-allow-multiple-definition
+ PATH: C:\MinGW\bin;%PATH%
+
+
+install:
+ - cd ..
+ - git clone -b %APPVEYOR_REPO_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
+ - cd boost-root
+ - git submodule update --init tools/build
+ - git submodule update --init libs/config
+ - git submodule update --init libs/core
+ - git submodule update --init libs/detail
+ - git submodule update --init libs/assert
+ - git submodule update --init libs/static_assert
+ - git submodule update --init libs/type_traits
+ - git submodule update --init libs/mpl
+ - git submodule update --init libs/preprocessor
+ - git submodule update --init libs/multiprecision
+ - git submodule update --init libs/math
+ - git submodule update --init libs/rational
+ - git submodule update --init libs/throw_exception
+ - git submodule update --init libs/predef
+ - git submodule update --init libs/lexical_cast
+ - git submodule update --init libs/range
+ - git submodule update --init libs/iterator
+ - git submodule update --init libs/concept_check
+ - git submodule update --init libs/numeric
+ - git submodule update --init libs/array
+ - git submodule update --init libs/container
+ - git submodule update --init libs/move
+ - git submodule update --init libs/functional
+ - git submodule update --init libs/random
+ - git submodule update --init libs/utility
+ - xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\integer
+ - bootstrap
+ - b2 headers
+
+build: off
+
+test_script:
+ - cd libs\config\test
+ - ..\..\..\b2 config_info_travis_install %ARGS%
+ - config_info_travis
+ - cd ..\..\integer\test
+ - ..\..\..\b2 -j3 %ARGS% define=CI_SUPPRESS_KNOWN_ISSUES
diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2
new file mode 100644
index 0000000..22d3eca
--- /dev/null
+++ b/doc/Jamfile.v2
@@ -0,0 +1,60 @@
+
+
+# Copyright John Maddock 2005. Use, modification, and distribution are
+# subject to the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+using quickbook ;
+
+xml integer : integer.qbk ;
+boostbook standalone
+ :
+ integer
+ :
+ # HTML options first:
+ # Use graphics not text for navigation:
+ <xsl:param>navig.graphics=1
+ # How far down we chunk nested sections, basically all of them:
+ <xsl:param>chunk.section.depth=1
+ # Don't put the first section on the same page as the TOC:
+ <xsl:param>chunk.first.sections=0
+ # How far down sections get TOC's
+ <xsl:param>toc.section.depth=1
+ # Max depth in each TOC:
+ <xsl:param>toc.max.depth=1
+ # How far down we go with TOC's
+ <xsl:param>generate.section.toc.level=4
+ # Path for links to Boost:
+ <xsl:param>boost.root=../../../..
+
+ # PDF Options:
+ # TOC Generation: this is needed for FOP-0.9 and later:
+ <xsl:param>fop1.extensions=0
+ # Or enable this if you're using XEP:
+ <xsl:param>xep.extensions=1
+ # TOC generation: this is needed for FOP 0.2, but must not be set to zero for FOP-0.9!
+ <xsl:param>fop.extensions=0
+ # No indent on body text:
+ <xsl:param>body.start.indent=0pt
+ # Margin size:
+ <xsl:param>page.margin.inner=0.5in
+ # Margin size:
+ <xsl:param>page.margin.outer=0.5in
+ # Yes, we want graphics for admonishments:
+ <xsl:param>admon.graphics=1
+ # Set this one for PDF generation *only*:
+ # default pnd graphics are awful in PDF form,
+ # better use SVG's instead:
+ <format>pdf:<xsl:param>admon.graphics.extension=".svg"
+ <format>pdf:<xsl:param>admon.graphics.path=$(boost-images)/
+ <format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/regex/doc/html
+ ;
+
+install pdfinstall : standalone/<format>pdf : <location>. <install-type>PDF ;
+explicit pdfinstall ;
+
+###############################################################################
+alias boostdoc ;
+explicit boostdoc ;
+alias boostrelease : standalone ;
+explicit boostrelease ;
diff --git a/doc/gcd/math-gcd.qbk b/doc/gcd/math-gcd.qbk
new file mode 100644
index 0000000..23472de
--- /dev/null
+++ b/doc/gcd/math-gcd.qbk
@@ -0,0 +1,292 @@
+
+[section:gcd_lcm Greatest Common Divisor and Least Common Multiple]
+
+[section Introduction]
+
+The class and function templates in <boost/math/common_factor.hpp>
+provide run-time and compile-time evaluation of the greatest common divisor
+(GCD) or least common multiple (LCM) of two integers.
+These facilities are useful for many numeric-oriented generic
+programming problems.
+
+[endsect]
+
+[section Synopsis]
+
+ namespace boost
+ {
+ namespace 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 );
+ template < typename IntegerType, typename... Args >
+ constexpr IntegerType gcd( IntegerType const &a, IntegerType const &b, Args const&... );
+ template < typename IntegerType, typename... Args >
+ constexpr IntegerType lcm( IntegerType const &a, IntegerType const &b, Args const&... );
+
+ template <typename I>
+ std::pair<typename std::iterator_traits<I>::value_type, I>
+ gcd_range(I first, I last);
+ template <typename I>
+ std::pair<typename std::iterator_traits<I>::value_type, I>
+ lcm_range(I first, I last);
+
+ typedef ``['see-below]`` static_gcd_type;
+
+ template < static_gcd_type Value1, static_gcd_type Value2 >
+ struct static_gcd;
+ template < static_gcd_type Value1, static_gcd_type Value2 >
+ struct static_lcm;
+
+ }
+ }
+
+[endsect]
+
+[section GCD Function Object]
+
+[*Header: ] [@../../../../boost/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 );
+
+ template < typename IntegerType, typename... Args >
+ constexpr IntegerType gcd( IntegerType const &a, IntegerType const &b, Args const&... );
+
+ template < typename IntegerType, typename... Args >
+ constexpr IntegerType lcm( IntegerType const &a, IntegerType const &b, Args const&... );
+
+ template <typename I>
+ std::pair<typename std::iterator_traits<I>::value_type, I>
+ gcd_range(I first, I last);
+
+ template <typename I>
+ std::pair<typename std::iterator_traits<I>::value_type, I>
+ lcm_range(I first, I last);
+
+The boost::math::gcd function template returns the greatest common
+(nonnegative) divisor of the two integers passed to it.
+`boost::math::gcd_range` is the iteration of the above gcd algorithm over a
+range, returning the greatest common divisor of all the elements. The algorithm
+terminates when the gcd reaches unity or the end of the range. Thus it also
+returns the iterator after the last element inspected because this may not be
+equal to the end of the range. The variadic version of `gcd` behaves similarly
+but does not indicate which input value caused the gcd to reach unity.
+
+The boost::math::lcm function template returns the least common
+(nonnegative) multiple of the two integers passed to it.
+As with gcd, there are range and variadic versions of the function for
+more than 2 arguments.
+
+Note that these functions are constexpr in C++14 and later only.
+They are also declared `noexcept` when appropriate.
+
+[endsect]
+
+[section:compile_time Compile time GCD and LCM determination]
+
+[note These functions are deprecated in favor of constexpr `gcd` and `lcm` on C++14 capable compilers.]
+
+[*Header: ] [@../../../../boost/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]
+
+* 24th April 2017 Moved to Jeremy Murphy's improved algorithms, added constexpr and noexcept support,
+added compiler intrinsic support, added variadic and range based versions of the algorithms.
+* 13 May 2013 Moved into main Boost.Math Quickbook documentation.
+* 17 Dec 2005: Converted documentation to Quickbook Format.
+* 2 Jul 2002: Compile-time and run-time items separated to new headers.
+* 7 Nov 2001: Initial version
+
+[endsect]
+
+[section:gcd_credits Credits]
+
+The author of the Boost compilation of GCD and LCM computations is
+Daryle Walker. The code was prompted by existing code hiding in the
+implementations of Paul Moore's rational library and Steve Cleary's
+pool library. The code had updates by Helmut Zeisel.
+
+[endsect]
+
+[endsect]
+
+[/
+Copyright 2005, 2013 Daryle Walker.
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt).
+]
+
+
diff --git a/doc/html/boost_integer/cstdint.html b/doc/html/boost_integer/cstdint.html
new file mode 100644
index 0000000..cb0223f
--- /dev/null
+++ b/doc/html/boost_integer/cstdint.html
@@ -0,0 +1,49 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<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.77.1">
+<link rel="home" href="../index.html" title="Boost.Integer">
+<link rel="up" href="../index.html" title="Boost.Integer">
+<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>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<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="Removed from library: Standard Integer Types">Removed from library: Standard Integer
+ Types</a>
+</h2></div></div></div>
+<p>
+ 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>
+</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 © 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>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<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>
diff --git a/doc/html/boost_integer/gcd_lcm.html b/doc/html/boost_integer/gcd_lcm.html
new file mode 100644
index 0000000..097afc0
--- /dev/null
+++ b/doc/html/boost_integer/gcd_lcm.html
@@ -0,0 +1,400 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Greatest Common Divisor and Least Common Multiple</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<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">
+<link rel="next" href="mask.html" title="Integer Masks">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="integer.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="mask.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.gcd_lcm"></a><a class="link" href="gcd_lcm.html" title="Greatest Common Divisor and Least Common Multiple">Greatest Common Divisor and Least
+ Common Multiple</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="gcd_lcm.html#boost_integer.gcd_lcm.introduction">Introduction</a></span></dt>
+<dt><span class="section"><a href="gcd_lcm.html#boost_integer.gcd_lcm.synopsis">Synopsis</a></span></dt>
+<dt><span class="section"><a href="gcd_lcm.html#boost_integer.gcd_lcm.gcd_function_object">GCD Function
+ Object</a></span></dt>
+<dt><span class="section"><a href="gcd_lcm.html#boost_integer.gcd_lcm.lcm_function_object">LCM Function
+ Object</a></span></dt>
+<dt><span class="section"><a href="gcd_lcm.html#boost_integer.gcd_lcm.run_time">Run-time GCD & LCM
+ Determination</a></span></dt>
+<dt><span class="section"><a href="gcd_lcm.html#boost_integer.gcd_lcm.compile_time">Compile time GCD
+ and LCM determination</a></span></dt>
+<dt><span class="section"><a href="gcd_lcm.html#boost_integer.gcd_lcm.gcd_header">Header <boost/math/common_factor.hpp></a></span></dt>
+<dt><span class="section"><a href="gcd_lcm.html#boost_integer.gcd_lcm.demo">Demonstration Program</a></span></dt>
+<dt><span class="section"><a href="gcd_lcm.html#boost_integer.gcd_lcm.rationale">Rationale</a></span></dt>
+<dt><span class="section"><a href="gcd_lcm.html#boost_integer.gcd_lcm.gcd_history">History</a></span></dt>
+<dt><span class="section"><a href="gcd_lcm.html#boost_integer.gcd_lcm.gcd_credits">Credits</a></span></dt>
+</dl></div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.gcd_lcm.introduction"></a><a class="link" href="gcd_lcm.html#boost_integer.gcd_lcm.introduction" title="Introduction">Introduction</a>
+</h3></div></div></div>
+<p>
+ 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.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.gcd_lcm.synopsis"></a><a class="link" href="gcd_lcm.html#boost_integer.gcd_lcm.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="keyword">namespace</span> <span class="identifier">math</span>
+<span class="special">{</span>
+
+<span class="keyword">template</span> <span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">IntegerType</span> <span class="special">></span>
+ <span class="keyword">class</span> <span class="identifier">gcd_evaluator</span><span class="special">;</span>
+<span class="keyword">template</span> <span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">IntegerType</span> <span class="special">></span>
+ <span class="keyword">class</span> <span class="identifier">lcm_evaluator</span><span class="special">;</span>
+
+<span class="keyword">template</span> <span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">IntegerType</span> <span class="special">></span>
+ <span class="keyword">constexpr</span> <span class="identifier">IntegerType</span> <span class="identifier">gcd</span><span class="special">(</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">b</span> <span class="special">);</span>
+<span class="keyword">template</span> <span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">IntegerType</span> <span class="special">></span>
+ <span class="keyword">constexpr</span> <span class="identifier">IntegerType</span> <span class="identifier">lcm</span><span class="special">(</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">b</span> <span class="special">);</span>
+<span class="keyword">template</span> <span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">IntegerType</span><span class="special">,</span> <span class="keyword">typename</span><span class="special">...</span> <span class="identifier">Args</span> <span class="special">></span>
+ <span class="keyword">constexpr</span> <span class="identifier">IntegerType</span> <span class="identifier">gcd</span><span class="special">(</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">b</span><span class="special">,</span> <span class="identifier">Args</span> <span class="keyword">const</span><span class="special">&...</span> <span class="special">);</span>
+<span class="keyword">template</span> <span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">IntegerType</span><span class="special">,</span> <span class="keyword">typename</span><span class="special">...</span> <span class="identifier">Args</span> <span class="special">></span>
+ <span class="keyword">constexpr</span> <span class="identifier">IntegerType</span> <span class="identifier">lcm</span><span class="special">(</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">b</span><span class="special">,</span> <span class="identifier">Args</span> <span class="keyword">const</span><span class="special">&...</span> <span class="special">);</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">I</span><span class="special">></span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">iterator_traits</span><span class="special"><</span><span class="identifier">I</span><span class="special">>::</span><span class="identifier">value_type</span><span class="special">,</span> <span class="identifier">I</span><span class="special">></span>
+ <span class="identifier">gcd_range</span><span class="special">(</span><span class="identifier">I</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">I</span> <span class="identifier">last</span><span class="special">);</span>
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">I</span><span class="special">></span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">iterator_traits</span><span class="special"><</span><span class="identifier">I</span><span class="special">>::</span><span class="identifier">value_type</span><span class="special">,</span> <span class="identifier">I</span><span class="special">></span>
+ <span class="identifier">lcm_range</span><span class="special">(</span><span class="identifier">I</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">I</span> <span class="identifier">last</span><span class="special">);</span>
+
+<span class="keyword">typedef</span> <span class="emphasis"><em>see-below</em></span> <span class="identifier">static_gcd_type</span><span class="special">;</span>
+
+<span class="keyword">template</span> <span class="special"><</span> <span class="identifier">static_gcd_type</span> <span class="identifier">Value1</span><span class="special">,</span> <span class="identifier">static_gcd_type</span> <span class="identifier">Value2</span> <span class="special">></span>
+ <span class="keyword">struct</span> <span class="identifier">static_gcd</span><span class="special">;</span>
+<span class="keyword">template</span> <span class="special"><</span> <span class="identifier">static_gcd_type</span> <span class="identifier">Value1</span><span class="special">,</span> <span class="identifier">static_gcd_type</span> <span class="identifier">Value2</span> <span class="special">></span>
+ <span class="keyword">struct</span> <span class="identifier">static_lcm</span><span class="special">;</span>
+
+<span class="special">}</span>
+<span class="special">}</span>
+</pre>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.gcd_lcm.gcd_function_object"></a><a class="link" href="gcd_lcm.html#boost_integer.gcd_lcm.gcd_function_object" title="GCD Function Object">GCD Function
+ Object</a>
+</h3></div></div></div>
+<p>
+ <span class="bold"><strong>Header: </strong></span> <a href="../../../../../boost/math/common_factor_rt.hpp" target="_top"><boost/math/common_factor_rt.hpp></a>
+ </p>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">IntegerType</span> <span class="special">></span>
+<span class="keyword">class</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">gcd_evaluator</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="comment">// Types</span>
+ <span class="keyword">typedef</span> <span class="identifier">IntegerType</span> <span class="identifier">result_type</span><span class="special">;</span>
+ <span class="keyword">typedef</span> <span class="identifier">IntegerType</span> <span class="identifier">first_argument_type</span><span class="special">;</span>
+ <span class="keyword">typedef</span> <span class="identifier">IntegerType</span> <span class="identifier">second_argument_type</span><span class="special">;</span>
+
+ <span class="comment">// Function object interface</span>
+ <span class="keyword">constexpr</span> <span class="identifier">result_type</span> <span class="keyword">operator</span> <span class="special">()(</span>
+ <span class="identifier">first_argument_type</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span>
+ <span class="identifier">second_argument_type</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">b</span> <span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
+<span class="special">};</span>
+</pre>
+<p>
+ 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.
+ </p>
+<p>
+ 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.
+ </p>
+<p>
+ Note that these function objects are <code class="computeroutput"><span class="keyword">constexpr</span></code>
+ in C++14 and later only. They are also declared <code class="computeroutput"><span class="keyword">noexcept</span></code>
+ when appropriate.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.gcd_lcm.lcm_function_object"></a><a class="link" href="gcd_lcm.html#boost_integer.gcd_lcm.lcm_function_object" title="LCM Function Object">LCM Function
+ Object</a>
+</h3></div></div></div>
+<p>
+ <span class="bold"><strong>Header: </strong></span> <a href="../../../../../boost/math/common_factor_rt.hpp" target="_top"><boost/math/common_factor_rt.hpp></a>
+ </p>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">IntegerType</span> <span class="special">></span>
+<span class="keyword">class</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">lcm_evaluator</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="comment">// Types</span>
+ <span class="keyword">typedef</span> <span class="identifier">IntegerType</span> <span class="identifier">result_type</span><span class="special">;</span>
+ <span class="keyword">typedef</span> <span class="identifier">IntegerType</span> <span class="identifier">first_argument_type</span><span class="special">;</span>
+ <span class="keyword">typedef</span> <span class="identifier">IntegerType</span> <span class="identifier">second_argument_type</span><span class="special">;</span>
+
+ <span class="comment">// Function object interface</span>
+ <span class="keyword">constexpr</span> <span class="identifier">result_type</span> <span class="keyword">operator</span> <span class="special">()(</span>
+ <span class="identifier">first_argument_type</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span>
+ <span class="identifier">second_argument_type</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">b</span> <span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
+<span class="special">};</span>
+</pre>
+<p>
+ 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.
+ </p>
+<p>
+ 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.
+ </p>
+<p>
+ Note that these function objects are constexpr in C++14 and later only. They
+ are also declared <code class="computeroutput"><span class="keyword">noexcept</span></code> when
+ appropriate.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.gcd_lcm.run_time"></a><a class="link" href="gcd_lcm.html#boost_integer.gcd_lcm.run_time" title="Run-time GCD & LCM Determination">Run-time GCD & LCM
+ Determination</a>
+</h3></div></div></div>
+<p>
+ <span class="bold"><strong>Header: </strong></span> <a href="../../../../../boost/math/common_factor_rt.hpp" target="_top"><boost/math/common_factor_rt.hpp></a>
+ </p>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">IntegerType</span> <span class="special">></span>
+<span class="keyword">constexpr</span> <span class="identifier">IntegerType</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">gcd</span><span class="special">(</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">b</span> <span class="special">);</span>
+
+<span class="keyword">template</span> <span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">IntegerType</span> <span class="special">></span>
+<span class="keyword">constexpr</span> <span class="identifier">IntegerType</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">lcm</span><span class="special">(</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">b</span> <span class="special">);</span>
+
+<span class="keyword">template</span> <span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">IntegerType</span><span class="special">,</span> <span class="keyword">typename</span><span class="special">...</span> <span class="identifier">Args</span> <span class="special">></span>
+ <span class="keyword">constexpr</span> <span class="identifier">IntegerType</span> <span class="identifier">gcd</span><span class="special">(</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">b</span><span class="special">,</span> <span class="identifier">Args</span> <span class="keyword">const</span><span class="special">&...</span> <span class="special">);</span>
+
+<span class="keyword">template</span> <span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">IntegerType</span><span class="special">,</span> <span class="keyword">typename</span><span class="special">...</span> <span class="identifier">Args</span> <span class="special">></span>
+ <span class="keyword">constexpr</span> <span class="identifier">IntegerType</span> <span class="identifier">lcm</span><span class="special">(</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">b</span><span class="special">,</span> <span class="identifier">Args</span> <span class="keyword">const</span><span class="special">&...</span> <span class="special">);</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">I</span><span class="special">></span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">iterator_traits</span><span class="special"><</span><span class="identifier">I</span><span class="special">>::</span><span class="identifier">value_type</span><span class="special">,</span> <span class="identifier">I</span><span class="special">></span>
+ <span class="identifier">gcd_range</span><span class="special">(</span><span class="identifier">I</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">I</span> <span class="identifier">last</span><span class="special">);</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">I</span><span class="special">></span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">iterator_traits</span><span class="special"><</span><span class="identifier">I</span><span class="special">>::</span><span class="identifier">value_type</span><span class="special">,</span> <span class="identifier">I</span><span class="special">></span>
+ <span class="identifier">lcm_range</span><span class="special">(</span><span class="identifier">I</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">I</span> <span class="identifier">last</span><span class="special">);</span>
+</pre>
+<p>
+ The boost::math::gcd function template returns the greatest common (nonnegative)
+ divisor of the two integers passed to it. <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">gcd_range</span></code>
+ is the iteration of the above gcd algorithm over a range, returning the greatest
+ common divisor of all the elements. The algorithm terminates when the gcd
+ reaches unity or the end of the range. Thus it also returns the iterator
+ after the last element inspected because this may not be equal to the end
+ of the range. The variadic version of <code class="computeroutput"><span class="identifier">gcd</span></code>
+ behaves similarly but does not indicate which input value caused the gcd
+ to reach unity.
+ </p>
+<p>
+ The boost::math::lcm function template returns the least common (nonnegative)
+ multiple of the two integers passed to it. As with gcd, there are range and
+ variadic versions of the function for more than 2 arguments.
+ </p>
+<p>
+ Note that these functions are constexpr in C++14 and later only. They are
+ also declared <code class="computeroutput"><span class="keyword">noexcept</span></code> when
+ appropriate.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.gcd_lcm.compile_time"></a><a class="link" href="gcd_lcm.html#boost_integer.gcd_lcm.compile_time" title="Compile time GCD and LCM determination">Compile time GCD
+ and LCM determination</a>
+</h3></div></div></div>
+<div class="note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ These functions are deprecated in favor of constexpr <code class="computeroutput"><span class="identifier">gcd</span></code>
+ and <code class="computeroutput"><span class="identifier">lcm</span></code> on C++14 capable
+ compilers.
+ </p></td></tr>
+</table></div>
+<p>
+ <span class="bold"><strong>Header: </strong></span> <a href="../../../../../boost/math/common_factor_ct.hpp" target="_top"><boost/math/common_factor_ct.hpp></a>
+ </p>
+<pre class="programlisting"><span class="keyword">typedef</span> <span class="emphasis"><em>unspecified</em></span> <span class="identifier">static_gcd_type</span><span class="special">;</span>
+
+<span class="keyword">template</span> <span class="special"><</span> <span class="identifier">static_gcd_type</span> <span class="identifier">Value1</span><span class="special">,</span> <span class="identifier">static_gcd_type</span> <span class="identifier">Value2</span> <span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">static_gcd</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><</span><span class="identifier">static_gcd_type</span><span class="special">,</span> <span class="identifier">implementation_defined</span><span class="special">></span>
+<span class="special">{</span>
+<span class="special">};</span>
+
+<span class="keyword">template</span> <span class="special"><</span> <span class="identifier">static_gcd_type</span> <span class="identifier">Value1</span><span class="special">,</span> <span class="identifier">static_gcd_type</span> <span class="identifier">Value2</span> <span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">static_lcm</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><</span><span class="identifier">static_gcd_type</span><span class="special">,</span> <span class="identifier">implementation_defined</span><span class="special">></span>
+<span class="special">{</span>
+<span class="special">};</span>
+</pre>
+<p>
+ The type <code class="computeroutput"><span class="identifier">static_gcd_type</span></code>
+ is the widest unsigned-integer-type that is supported for use in integral-constant-expressions
+ by the compiler. Usually this the same type as <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">uintmax_t</span></code>,
+ but may fall back to being <code class="computeroutput"><span class="keyword">unsigned</span>
+ <span class="keyword">long</span></code> for some older compilers.
+ </p>
+<p>
+ The boost::math::static_gcd and boost::math::static_lcm class templates take
+ two value-based template parameters of the <span class="emphasis"><em>static_gcd_type</em></span>
+ type and inherit from the type <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span></code>. Inherited from the base class,
+ they have a member <span class="emphasis"><em>value</em></span> 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 <code class="computeroutput"><span class="identifier">static_gcd_type</span></code>.
+ </p>
+<h4>
+<a name="boost_integer.gcd_lcm.compile_time.h0"></a>
+ <span class="phrase"><a name="boost_integer.gcd_lcm.compile_time.example"></a></span><a class="link" href="gcd_lcm.html#boost_integer.gcd_lcm.compile_time.example">Example</a>
+ </h4>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">common_factor</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">;</span>
+ <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"The GCD and LCM of 6 and 15 are "</span>
+ <span class="special"><<</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">gcd</span><span class="special">(</span><span class="number">6</span><span class="special">,</span> <span class="number">15</span><span class="special">)</span> <span class="special"><<</span> <span class="string">" and "</span>
+ <span class="special"><<</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">lcm</span><span class="special">(</span><span class="number">6</span><span class="special">,</span> <span class="number">15</span><span class="special">)</span> <span class="special"><<</span> <span class="string">", respectively."</span>
+ <span class="special"><<</span> <span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"The GCD and LCM of 8 and 9 are "</span>
+ <span class="special"><<</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">static_gcd</span><span class="special"><</span><span class="number">8</span><span class="special">,</span> <span class="number">9</span><span class="special">>::</span><span class="identifier">value</span>
+ <span class="special"><<</span> <span class="string">" and "</span>
+ <span class="special"><<</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">static_lcm</span><span class="special"><</span><span class="number">8</span><span class="special">,</span> <span class="number">9</span><span class="special">>::</span><span class="identifier">value</span>
+ <span class="special"><<</span> <span class="string">", respectively."</span> <span class="special"><<</span> <span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="keyword">int</span> <span class="identifier">a</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">4</span><span class="special">,</span> <span class="number">5</span><span class="special">,</span> <span class="number">6</span> <span class="special">},</span> <span class="identifier">b</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">7</span><span class="special">,</span> <span class="number">8</span><span class="special">,</span> <span class="number">9</span> <span class="special">},</span> <span class="identifier">c</span><span class="special">[</span><span class="number">3</span><span class="special">];</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">transform</span><span class="special">(</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">a</span> <span class="special">+</span> <span class="number">3</span><span class="special">,</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">c</span><span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">gcd_evaluator</span><span class="special"><</span><span class="keyword">int</span><span class="special">>()</span> <span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span> <span class="identifier">c</span><span class="special">,</span> <span class="identifier">c</span> <span class="special">+</span> <span class="number">3</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream_iterator</span><span class="special"><</span><span class="keyword">int</span><span class="special">>(</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">" "</span><span class="special">)</span> <span class="special">);</span>
+<span class="special">}</span>
+</pre>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.gcd_lcm.gcd_header"></a><a class="link" href="gcd_lcm.html#boost_integer.gcd_lcm.gcd_header" title="Header <boost/math/common_factor.hpp>">Header <boost/math/common_factor.hpp></a>
+</h3></div></div></div>
+<p>
+ This header simply includes the headers <a href="../../../../../boost/math/common_factor_ct.hpp" target="_top"><boost/math/common_factor_ct.hpp></a>
+ and <a href="../../../../../boost/math/common_factor_rt.hpp" target="_top"><boost/math/common_factor_rt.hpp></a>.
+ </p>
+<p>
+ 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).
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.gcd_lcm.demo"></a><a class="link" href="gcd_lcm.html#boost_integer.gcd_lcm.demo" title="Demonstration Program">Demonstration Program</a>
+</h3></div></div></div>
+<p>
+ The program <a href="../../../../../libs/math/test/common_factor_test.cpp" target="_top">common_factor_test.cpp</a>
+ 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.)
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.gcd_lcm.rationale"></a><a class="link" href="gcd_lcm.html#boost_integer.gcd_lcm.rationale" title="Rationale">Rationale</a>
+</h3></div></div></div>
+<p>
+ 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.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.gcd_lcm.gcd_history"></a><a class="link" href="gcd_lcm.html#boost_integer.gcd_lcm.gcd_history" title="History">History</a>
+</h3></div></div></div>
+<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
+<li class="listitem">
+ 24th April 2017 Moved to Jeremy Murphy's improved algorithms, added constexpr
+ and noexcept support, added compiler intrinsic support, added variadic
+ and range based versions of the algorithms.
+ </li>
+<li class="listitem">
+ 13 May 2013 Moved into main Boost.Math Quickbook documentation.
+ </li>
+<li class="listitem">
+ 17 Dec 2005: Converted documentation to Quickbook Format.
+ </li>
+<li class="listitem">
+ 2 Jul 2002: Compile-time and run-time items separated to new headers.
+ </li>
+<li class="listitem">
+ 7 Nov 2001: Initial version
+ </li>
+</ul></div>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.gcd_lcm.gcd_credits"></a><a class="link" href="gcd_lcm.html#boost_integer.gcd_lcm.gcd_credits" title="Credits">Credits</a>
+</h3></div></div></div>
+<p>
+ 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.
+ </p>
+</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 © 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>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="integer.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="mask.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/doc/html/boost_integer/history.html b/doc/html/boost_integer/history.html
new file mode 100644
index 0000000..77257ba
--- /dev/null
+++ b/doc/html/boost_integer/history.html
@@ -0,0 +1,90 @@
+<html>
+<head>
+<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.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>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</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="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>
+</h2></div></div></div>
+<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" style="list-style-type: disc; "><li class="listitem">
+ Moved <code class="computeroutput"><span class="special"><</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">></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>
+<li class="listitem">
+ Fixed issues: <a href="https://svn.boost.org/trac/boost/ticket/653" target="_top">653</a>,
+ <a href="https://svn.boost.org/trac/boost/ticket/3084" target="_top">3084</a>,
+ <a href="https://svn.boost.org/trac/boost/ticket/3177" target="_top">3177</a>,
+ <a href="https://svn.boost.org/trac/boost/ticket/3180" target="_top">3180</a>,
+ <a href="https://svn.boost.org/trac/boost/ticket/3548" target="_top">3568</a>,
+ <a href="https://svn.boost.org/trac/boost/ticket/3657" target="_top">3657</a>,
+ <a href="https://svn.boost.org/trac/boost/ticket/2134" target="_top">2134</a>.
+ </li>
+<li class="listitem">
+ Added long long support to <code class="literal">boost::static_log2</code>, <code class="literal">boost::static_signed_min</code>,
+ <code class="literal">boost::static_signed_max</code>, <code class="literal">boost::static_unsigned_min</code><code class="literal">boost::static_unsigned_max</code>,
+ when available.
+ </li>
+<li class="listitem">
+ The argument type and the result type of <code class="literal">boost::static_signed_min</code>
+ etc 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 in new code (and update old code as soon as possible).
+ </li>
+</ul></div>
+<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" 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
+ in new code (and update old code as soon as possible).
+ </li></ul></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 © 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>
+</div></td>
+</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="n" href="cstdint.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/doc/html/boost_integer/integer.html b/doc/html/boost_integer/integer.html
new file mode 100644
index 0000000..6dc60ef
--- /dev/null
+++ b/doc/html/boost_integer/integer.html
@@ -0,0 +1,432 @@
+<html>
+<head>
+<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.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">
+<link rel="next" href="gcd_lcm.html" title="Greatest Common Divisor and Least Common Multiple">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="traits.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="gcd_lcm.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.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
+ 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>
+<dt><span class="section"><a href="integer.html#boost_integer.integer.rationale">Rationale</a></span></dt>
+<dt><span class="section"><a href="integer.html#boost_integer.integer.alternative">Alternative</a></span></dt>
+<dt><span class="section"><a href="integer.html#boost_integer.integer.credits">Credits</a></span></dt>
+</dl></div>
+<p>
+ The <a href="../../../../../boost/integer.hpp" target="_top"><boost/integer.hpp></a>
+ type selection templates allow integer types to be selected based on desired
+ characteristics such as number of bits or maximum value. This facility is particularly
+ useful for solving generic programming problems.
+ </p>
+<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>
+</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"><</span><span class="keyword">typename</span> <span class="identifier">LeastInt</span><span class="special">></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"><</span><span class="keyword">int</span> <span class="identifier">Bits</span><span class="special">></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>
+ <span class="keyword">typedef</span> <span class="emphasis"><em>implementation-defined-type</em></span> <span class="identifier">exact</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"><</span><span class="identifier">least</span><span class="special">>::</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"><</span><span class="keyword">int</span> <span class="identifier">Bits</span><span class="special">></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>
+ <span class="keyword">typedef</span> <span class="emphasis"><em>implementation-defined-type</em></span> <span class="identifier">exact</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"><</span><span class="identifier">least</span><span class="special">>::</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"><</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">MaxValue</span><span class="special">></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>
+ <span class="keyword">typedef</span> <span class="identifier">int_fast_t</span><span class="special"><</span><span class="identifier">least</span><span class="special">>::</span><span class="identifier">fast</span> <span class="identifier">fast</span><span class="special">;</span>
+ <span class="special">};</span>
+
+ <span class="keyword">template</span><span class="special"><</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">MinValue</span><span class="special">></span>
+ <span class="keyword">struct</span> <span class="identifier">int_min_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"><</span><span class="identifier">least</span><span class="special">>::</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"><</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">Value</span><span class="special">></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"><</span><span class="identifier">least</span><span class="special">>::</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>
+</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
+ Types</a>
+</h3></div></div></div>
+<p>
+ The <code class="literal">int_fast_t</code> class template maps its input type to the
+ next-largest type that the processor can manipulate the easiest, or to itself
+ if the input type is already an easy-to-manipulate type. For instance, processing
+ a bunch of <code class="literal">char</code> objects may go faster if they were converted
+ to <code class="literal">int</code> objects before processing. The input type, passed
+ as the only template parameter, must be a built-in integral type, except
+ <code class="literal">bool</code>. Unsigned integral types can be used, as well as
+ signed integral types. The output type is given as the nested type <code class="literal">fast</code>.
+ </p>
+<p>
+ <span class="bold"><strong>Implementation Notes:</strong></span> By default, the output
+ type is identical to the input type. Eventually, this code's implementation
+ should be customized for each platform to give accurate mappings between
+ the built-in types and the easiest-to-manipulate built-in types. Also, there
+ is no guarantee that the output type actually is easier to manipulate than
+ the input type.
+ </p>
+</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>
+</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>,
+ <code class="literal">int_min_value_t</code>, and <code class="literal">uint_value_t</code> class
+ templates find the most appropiate built-in integral type for the given template
+ parameter. This type is given by the nested type <code class="literal">least</code>.
+ The easiest-to-manipulate version of that type is given by the nested type
+ <code class="literal">fast</code>. The following table describes each template's criteria.
+ </p>
+<div class="table">
+<a name="boost_integer.integer.sized.criteria_for_the_sized_type_class_templates"></a><p class="title"><b>Table 1. Criteria for the Sized Type Class Templates</b></p>
+<div class="table-contents"><table class="table" summary="Criteria for the Sized Type Class Templates">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Class Template
+ </p>
+ </th>
+<th>
+ <p>
+ Template Parameter Mapping
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ <code class="literal">boost::int_t<N>::least</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The smallest, built-in, signed integral type with at least <span class="emphasis"><em>N</em></span>
+ bits, including the sign bit. The parameter should be a positive
+ number. A compile-time error results if the parameter is larger
+ than the number of bits in the largest integer type.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">boost::int_t<N>::fast</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The easiest-to-manipulate, built-in, signed integral type with
+ at least <span class="emphasis"><em>N</em></span> bits, including the sign bit. The
+ parameter should be a positive number. A compile-time error results
+ if the parameter is larger than the number of bits in the largest
+ integer type.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">boost::int_t<N>::exact</code>
+ </p>
+ </td>
+<td>
+ <p>
+ A built-in, signed integral type with exactly <span class="emphasis"><em>N</em></span>
+ bits, including the sign bit. The parameter should be a positive
+ number. Note that the member <span class="emphasis"><em>exact</em></span> is defined
+ <span class="bold"><strong>only</strong></span> if there exists a type with
+ exactly <span class="emphasis"><em>N</em></span> bits.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">boost::uint_t<N>::least</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The smallest, built-in, unsigned integral type with at least <span class="emphasis"><em>N</em></span>
+ bits. The parameter should be a positive number. A compile-time
+ error results if the parameter is larger than the number of bits
+ in the largest integer type.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">boost::uint_t<N>::fast</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The easiest-to-manipulate, built-in, unsigned integral type with
+ at least <span class="emphasis"><em>N</em></span> bits. The parameter should be a
+ positive number. A compile-time error results if the parameter
+ is larger than the number of bits in the largest integer type.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">boost::uint_t<N>::exact</code>
+ </p>
+ </td>
+<td>
+ <p>
+ A built-in, unsigned integral type with exactly <span class="emphasis"><em>N</em></span>
+ bits. The parameter should be a positive number. A compile-time
+ error results if the parameter is larger than the number of bits
+ in the largest integer type. Note that the member <span class="emphasis"><em>exact</em></span>
+ is defined <span class="bold"><strong>only</strong></span> if there exists
+ a type with exactly N bits.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">boost::int_max_value_t<V>::last</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The smallest, built-in, signed integral type that can hold all
+ the values in the inclusive range <span class="emphasis"><em>0 - V</em></span>. The
+ parameter should be a positive number.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">boost::int_max_value_t<V>::fast</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The easiest-to-manipulate, built-in, signed integral type that
+ can hold all the values in the inclusive range <span class="emphasis"><em>0 - V</em></span>.
+ The parameter should be a positive number.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">boost::int_min_value_t<V>::least</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The smallest, built-in, signed integral type that can hold all
+ the values in the inclusive range <span class="emphasis"><em>V - 0</em></span>. The
+ parameter should be a negative number.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">boost::int_min_value_t<V>::fast</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The easiest-to-manipulate, built-in, signed integral type that
+ can hold all the values in the inclusive range <span class="emphasis"><em>V - 0</em></span>.
+ The parameter should be a negative number.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">boost::uint_value_t<V>::least</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The smallest, built-in, unsigned integral type that can hold all
+ positive values up to and including <span class="emphasis"><em>V</em></span>. The
+ parameter should be a positive number.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">boost::uint_value_t<V>::fast</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The easiest-to-manipulate, built-in, unsigned integral type that
+ can hold all positive values up to and including <span class="emphasis"><em>V</em></span>.
+ The parameter should be a positive number.
+ </p>
+ </td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<br class="table-break">
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.integer.example"></a><a class="link" href="integer.html#boost_integer.integer.example" title="Example">Example</a>
+</h3></div></div></div>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">></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"><</span><span class="number">24</span><span class="special">>::</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"><</span><span class="number">1000</span><span class="special">>::</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"><</span><span class="number">1000</span><span class="special">>::</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>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.integer.demonstration_program"></a><a class="link" href="integer.html#boost_integer.integer.demonstration_program" title="Demonstration Program">Demonstration
+ Program</a>
+</h3></div></div></div>
+<p>
+ The program <a href="../../../test/integer_test.cpp" target="_top">integer_test.cpp</a>
+ is a simplistic demonstration of the results from instantiating various examples
+ of the sized type class templates.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.integer.rationale"></a><a class="link" href="integer.html#boost_integer.integer.rationale" title="Rationale">Rationale</a>
+</h3></div></div></div>
+<p>
+ The rationale for the design of the templates in this header includes:
+ </p>
+<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).
+ </li>
+<li class="listitem">
+ Avoid macros on general principles.
+ </li>
+<li class="listitem">
+ Try to keep the design as simple as possible.
+ </li>
+</ul></div>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.integer.alternative"></a><a class="link" href="integer.html#boost_integer.integer.alternative" title="Alternative">Alternative</a>
+</h3></div></div></div>
+<p>
+ If the number of bits required is known beforehand, it may be more appropriate
+ to use the types supplied in <a href="../../../../../boost/cstdint.hpp" target="_top"><boost/cstdint.hpp></a>.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.integer.credits"></a><a class="link" href="integer.html#boost_integer.integer.credits" title="Credits">Credits</a>
+</h3></div></div></div>
+<p>
+ The author of most of the Boost integer type choosing templates is <a href="http://www.boost.org/people/beman_dawes.html" target="_top">Beman Dawes</a>. He
+ gives thanks to Valentin Bonnard and <a href="http://www.boost.org/people/kevlin_henney.htm" target="_top">Kevlin
+ Henney</a> for sharing their designs for similar templates. <a href="http://www.boost.org/people/daryle_walker.html" target="_top">Daryle
+ Walker</a> designed the value-based sized templates.
+ </p>
+</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 © 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>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="traits.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="gcd_lcm.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/doc/html/boost_integer/log2.html b/doc/html/boost_integer/log2.html
new file mode 100644
index 0000000..19c1a21
--- /dev/null
+++ b/doc/html/boost_integer/log2.html
@@ -0,0 +1,151 @@
+<html>
+<head>
+<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.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">
+<link rel="next" href="minmax.html" title="Compile time min/max calculation">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="mask.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="minmax.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.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>
+<dt><span class="section"><a href="log2.html#boost_integer.log2.usage">Usage</a></span></dt>
+<dt><span class="section"><a href="log2.html#boost_integer.log2.demonstration_program">Demonstration
+ Program</a></span></dt>
+<dt><span class="section"><a href="log2.html#boost_integer.log2.rationale">Rationale</a></span></dt>
+<dt><span class="section"><a href="log2.html#boost_integer.log2.credits">Credits</a></span></dt>
+</dl></div>
+<p>
+ The class template in <a href="../../../../../boost/integer/static_log2.hpp" target="_top"><boost/integer/static_log2.hpp></a>
+ determines the position of the highest bit in a given value. This facility
+ is useful for solving generic programming problems.
+ </p>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.log2.synopsis"></a><a class="link" href="log2.html#boost_integer.log2.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="keyword">typedef</span> <span class="emphasis"><em>implementation-defined</em></span> <span class="identifier">static_log2_argument_type</span><span class="special">;</span>
+ <span class="keyword">typedef</span> <span class="emphasis"><em>implementation-defined</em></span> <span class="identifier">static_log2_result_type</span><span class="special">;</span>
+
+ <span class="keyword">template</span> <span class="special"><</span><span class="identifier">static_log2_argument_type</span> <span class="identifier">arg</span><span class="special">></span>
+ <span class="keyword">struct</span> <span class="identifier">static_log2</span>
+ <span class="special">{</span>
+ <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">static_log2_result_type</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span>
+ <span class="special">};</span>
+
+
+ <span class="keyword">template</span> <span class="special"><</span> <span class="special">></span>
+ <span class="keyword">struct</span> <span class="identifier">static_log2</span><span class="special"><</span> <span class="number">0</span> <span class="special">></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>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.log2.usage"></a><a class="link" href="log2.html#boost_integer.log2.usage" title="Usage">Usage</a>
+</h3></div></div></div>
+<p>
+ The <code class="literal">boost::static_log2</code> class template takes one template
+ parameter, a value of type <code class="literal">static_log2_argument_type</code>.
+ The template only defines one member, <code class="literal">value</code>, which gives
+ the truncated, base-two logarithm of the template argument.
+ </p>
+<p>
+ Since the logarithm of zero, for any base, is undefined, there is a specialization
+ of <code class="literal">static_log2</code> for a template argument of zero. This specialization
+ has no members, so an attempt to use the base-two logarithm of zero results
+ in a compile-time error.
+ </p>
+<p>
+ Note:
+ </p>
+<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).
+ </li>
+<li class="listitem">
+ <code class="literal">static_log2_result_type</code> is an <span class="emphasis"><em>integer type</em></span>
+ (C++ standard, 3.9.1p7).
+ </li>
+</ul></div>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.log2.demonstration_program"></a><a class="link" href="log2.html#boost_integer.log2.demonstration_program" title="Demonstration Program">Demonstration
+ Program</a>
+</h3></div></div></div>
+<p>
+ The program <a href="../../../test/static_log2_test.cpp" target="_top">static_log2_test.cpp</a>
+ is a simplistic demonstration of the results from instantiating various examples
+ of the binary logarithm class template.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.log2.rationale"></a><a class="link" href="log2.html#boost_integer.log2.rationale" title="Rationale">Rationale</a>
+</h3></div></div></div>
+<p>
+ The base-two (binary) logarithm, abbreviated lb, function is occasionally
+ used to give order-estimates of computer algorithms. The truncated logarithm
+ can be considered the highest power-of-two in a value, which corresponds
+ to the value's highest set bit (for binary integers). Sometimes the highest-bit
+ position could be used in generic programming, which requires the position
+ to be available statically (<span class="emphasis"><em>i.e.</em></span> at compile-time).
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.log2.credits"></a><a class="link" href="log2.html#boost_integer.log2.credits" title="Credits">Credits</a>
+</h3></div></div></div>
+<p>
+ The original version of the Boost binary logarithm class template was written
+ by <a href="http://www.boost.org/people/daryle_walker.html" target="_top">Daryle Walker</a>
+ and then enhanced by Giovanni Bajo with support for compilers without partial
+ template specialization. The current version was suggested, together with
+ a reference implementation, by Vesa Karvonen. Gennaro Prota wrote the actual
+ source file.
+ </p>
+</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 © 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>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="mask.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="minmax.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/doc/html/boost_integer/mask.html b/doc/html/boost_integer/mask.html
new file mode 100644
index 0000000..0d72e1e
--- /dev/null
+++ b/doc/html/boost_integer/mask.html
@@ -0,0 +1,380 @@
+<html>
+<head>
+<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.77.1">
+<link rel="home" href="../index.html" title="Boost.Integer">
+<link rel="up" href="../index.html" title="Boost.Integer">
+<link rel="prev" href="gcd_lcm.html" title="Greatest Common Divisor and Least Common Multiple">
+<link rel="next" href="log2.html" title="Compile Time log2 Calculation">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="gcd_lcm.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="log2.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.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>
+<dt><span class="section"><a href="mask.html#boost_integer.mask.synopsis">Synopsis</a></span></dt>
+<dt><span class="section"><a href="mask.html#boost_integer.mask.single_bit_mask_class_template">Single
+ Bit-Mask Class Template</a></span></dt>
+<dt><span class="section"><a href="mask.html#boost_integer.mask.group_bit_mask_class_template">Group
+ Bit-Mask Class Template</a></span></dt>
+<dt><span class="section"><a href="mask.html#boost_integer.mask.implementation_notes">Implementation
+ Notes</a></span></dt>
+<dt><span class="section"><a href="mask.html#boost_integer.mask.example">Example</a></span></dt>
+<dt><span class="section"><a href="mask.html#boost_integer.mask.demonstration_program">Demonstration
+ Program</a></span></dt>
+<dt><span class="section"><a href="mask.html#boost_integer.mask.rationale">Rationale</a></span></dt>
+<dt><span class="section"><a href="mask.html#boost_integer.mask.credits">Credits</a></span></dt>
+</dl></div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.mask.overview"></a><a class="link" href="mask.html#boost_integer.mask.overview" title="Overview">Overview</a>
+</h3></div></div></div>
+<p>
+ The class templates in <a href="../../../../../boost/integer/integer_mask.hpp" target="_top"><boost/integer/integer_mask.hpp></a>
+ provide bit masks for a certain bit position or a contiguous-bit pack of
+ a certain size. The types of the masking constants come from the <a class="link" href="integer.html" title="Integer Type Selection">integer
+ type selection templates</a> header.
+ </p>
+</div>
+<div class="section">
+<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"><</span><span class="identifier">cstddef</span><span class="special">></span> <span class="comment">// for std::size_t</span>
+
+<span class="keyword">namespace</span> <span class="identifier">boost</span>
+<span class="special">{</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">Bit</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">high_bit_mask_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="emphasis"><em>implementation-defined-type</em></span> <span class="identifier">fast</span><span class="special">;</span>
+
+ <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">least</span> <span class="identifier">high_bit</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">fast</span> <span class="identifier">high_bit_fast</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">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">bit_position</span> <span class="special">=</span> <span class="identifier">Bit</span><span class="special">;</span>
+<span class="special">};</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">Bits</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">low_bits_mask_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="emphasis"><em>implementation-defined-type</em></span> <span class="identifier">fast</span><span class="special">;</span>
+
+ <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">least</span> <span class="identifier">sig_bits</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">fast</span> <span class="identifier">sig_bits_fast</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">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>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.mask.single_bit_mask_class_template"></a><a class="link" href="mask.html#boost_integer.mask.single_bit_mask_class_template" title="Single Bit-Mask Class Template">Single
+ Bit-Mask Class Template</a>
+</h3></div></div></div>
+<p>
+ The <code class="literal">boost::high_bit_mask_t</code> class template provides constants
+ for bit masks representing the bit at a certain position. The masks are equivalent
+ to the value 2<sup>Bit</sup>, where <code class="literal">Bit</code> is the template parameter.
+ The bit position must be a nonnegative number from zero to <span class="emphasis"><em>Max</em></span>,
+ where Max is one less than the number of bits supported by the largest unsigned
+ built-in integral type. The following table describes the members of an instantiation
+ of <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 2. 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>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Member
+ </p>
+ </th>
+<th>
+ <p>
+ Meaning
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ <code class="literal">least</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The smallest, unsigned, built-in type that supports the given bit
+ position.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">fast</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The easiest-to-manipulate analog of <code class="literal">least</code>.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">high_bit</code>
+ </p>
+ </td>
+<td>
+ <p>
+ A <code class="literal">least</code> constant of the value 2<sup>Bit</sup>.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">high_bit_fast</code>
+ </p>
+ </td>
+<td>
+ <p>
+ A <code class="literal">fast</code> analog of <code class="literal">high_bit</code>.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">bit_position</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The value of the template parameter, in case its needed from a
+ renamed instantiation of the class template.
+ </p>
+ </td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<br class="table-break">
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.mask.group_bit_mask_class_template"></a><a class="link" href="mask.html#boost_integer.mask.group_bit_mask_class_template" title="Group Bit-Mask Class Template">Group
+ Bit-Mask Class Template</a>
+</h3></div></div></div>
+<p>
+ The <code class="literal">boost::low_bits_mask_t</code> class template provides constants
+ for bit masks equivalent to the value (2<sup>Bits</sup> - 1), where <code class="literal">Bits</code>
+ is the template parameter. The parameter <code class="literal">Bits</code> must be
+ a non-negative integer from zero to <span class="emphasis"><em>Max</em></span>, where Max is
+ the number of bits supported by the largest, unsigned, built-in integral
+ 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 3. 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>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Member
+ </p>
+ </th>
+<th>
+ <p>
+ Meaning
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ <code class="literal">least</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The smallest, unsigned built-in type that supports the given bit
+ count.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">fast</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The easiest-to-manipulate analog of <code class="literal">least</code>.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">sig_bits</code>
+ </p>
+ </td>
+<td>
+ <p>
+ A <code class="literal">least</code> constant of the desired bit-masking
+ value.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">sig_bits_fast</code>
+ </p>
+ </td>
+<td>
+ <p>
+ A <code class="literal">fast</code> analog of <code class="literal">sig_bits</code>.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">bit_count</code>
+ </p>
+ </td>
+<td>
+ <p>
+ The value of the template parameter, in case its needed from a
+ renamed instantiation of the class template.
+ </p>
+ </td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<br class="table-break">
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.mask.implementation_notes"></a><a class="link" href="mask.html#boost_integer.mask.implementation_notes" title="Implementation Notes">Implementation
+ Notes</a>
+</h3></div></div></div>
+<p>
+ When <code class="literal">Bits</code> is the exact size of a built-in unsigned type,
+ the implementation has to change to prevent undefined behavior. Therefore,
+ there are specializations of <code class="literal">low_bits_mask_t</code> at those
+ bit counts.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.mask.example"></a><a class="link" href="mask.html#boost_integer.mask.example" title="Example">Example</a>
+</h3></div></div></div>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">></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"><</span><span class="number">29</span><span class="special">></span> <span class="identifier">mask1_type</span><span class="special">;</span>
+ <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">low_bits_mask_t</span><span class="special"><</span><span class="number">15</span><span class="special">></span> <span class="identifier">mask2_type</span><span class="special">;</span>
+
+ <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="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">&=</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>
+</pre>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.mask.demonstration_program"></a><a class="link" href="mask.html#boost_integer.mask.demonstration_program" title="Demonstration Program">Demonstration
+ Program</a>
+</h3></div></div></div>
+<p>
+ The program <a href="../../../test/integer_mask_test.cpp" target="_top">integer_mask_test.cpp</a>
+ is a simplistic demonstration of the results from instantiating various examples
+ of the bit mask class templates.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.mask.rationale"></a><a class="link" href="mask.html#boost_integer.mask.rationale" title="Rationale">Rationale</a>
+</h3></div></div></div>
+<p>
+ The class templates in this header are an extension of the <a class="link" href="integer.html" title="Integer Type Selection">integer
+ type selection class templates</a>. The new class templates provide the
+ same sized types, but also convenient masks to use when extracting the highest
+ or all the significant bits when the containing built-in type contains more
+ bits. This prevents contamination of values by the higher, unused bits.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.mask.credits"></a><a class="link" href="mask.html#boost_integer.mask.credits" title="Credits">Credits</a>
+</h3></div></div></div>
+<p>
+ The author of the Boost bit mask class templates is <a href="http://www.boost.org/people/daryle_walker.html" target="_top">Daryle
+ Walker</a>.
+ </p>
+</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 © 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>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="gcd_lcm.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="log2.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/doc/html/boost_integer/minmax.html b/doc/html/boost_integer/minmax.html
new file mode 100644
index 0000000..d67425f
--- /dev/null
+++ b/doc/html/boost_integer/minmax.html
@@ -0,0 +1,160 @@
+<html>
+<head>
+<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.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">
+<link rel="next" href="history.html" title="History">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="log2.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="history.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.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>
+<dt><span class="section"><a href="minmax.html#boost_integer.minmax.usage">Usage</a></span></dt>
+<dt><span class="section"><a href="minmax.html#boost_integer.minmax.example">Example</a></span></dt>
+<dt><span class="section"><a href="minmax.html#boost_integer.minmax.demonstration_program">Demonstration
+ Program</a></span></dt>
+<dt><span class="section"><a href="minmax.html#boost_integer.minmax.rationale">Rationale</a></span></dt>
+<dt><span class="section"><a href="minmax.html#boost_integer.minmax.credits">Credits</a></span></dt>
+</dl></div>
+<p>
+ The class templates in <a href="../../../../../boost/integer/static_min_max.hpp" target="_top"><boost/integer/static_min_max.hpp></a>
+ provide a compile-time evaluation of the minimum or maximum of two integers.
+ These facilities are useful for generic programming problems.
+ </p>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.minmax.synopsis"></a><a class="link" href="minmax.html#boost_integer.minmax.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="keyword">typedef</span> <span class="emphasis"><em>implementation-defined</em></span> <span class="identifier">static_min_max_signed_type</span><span class="special">;</span>
+<span class="keyword">typedef</span> <span class="emphasis"><em>implementation-defined</em></span> <span class="identifier">static_min_max_unsigned_type</span><span class="special">;</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="identifier">static_min_max_signed_type</span> <span class="identifier">Value1</span><span class="special">,</span> <span class="identifier">static_min_max_signed_type</span> <span class="identifier">Value2</span> <span class="special">></span>
+ <span class="keyword">struct</span> <span class="identifier">static_signed_min</span><span class="special">;</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="identifier">static_min_max_signed_type</span> <span class="identifier">Value1</span><span class="special">,</span> <span class="identifier">static_min_max_signed_type</span> <span class="identifier">Value2</span><span class="special">></span>
+ <span class="keyword">struct</span> <span class="identifier">static_signed_max</span><span class="special">;</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="identifier">static_min_max_unsigned_type</span> <span class="identifier">Value1</span><span class="special">,</span> <span class="identifier">static_min_max_unsigned_type</span> <span class="identifier">Value2</span><span class="special">></span>
+ <span class="keyword">struct</span> <span class="identifier">static_unsigned_min</span><span class="special">;</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="identifier">static_min_max_unsigned_type</span> <span class="identifier">Value1</span><span class="special">,</span> <span class="identifier">static_min_max_unsigned_type</span> <span class="identifier">Value2</span><span class="special">></span>
+ <span class="keyword">struct</span> <span class="identifier">static_unsigned_max</span><span class="special">;</span>
+
+<span class="special">}</span>
+</pre>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.minmax.usage"></a><a class="link" href="minmax.html#boost_integer.minmax.usage" title="Usage">Usage</a>
+</h3></div></div></div>
+<p>
+ The four class templates provide the combinations for finding the minimum
+ or maximum of two <code class="literal">signed</code> or <code class="literal">unsigned</code>
+ (<code class="literal">long</code>) parameters, <span class="emphasis"><em>Value1</em></span> and <span class="emphasis"><em>Value2</em></span>,
+ at compile-time. Each template has a single static data member, <code class="literal">value</code>,
+ which is set to the respective minimum or maximum of the template's parameters.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.minmax.example"></a><a class="link" href="minmax.html#boost_integer.minmax.example" title="Example">Example</a>
+</h3></div></div></div>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">/</span><span class="identifier">static_min_max</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+
+<span class="keyword">template</span> <span class="special"><</span> <span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="identifier">AddendSize1</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="identifier">AddendSize2</span> <span class="special">></span>
+<span class="keyword">class</span> <span class="identifier">adder</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">static</span> <span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">const</span> <span class="identifier">addend1_size</span> <span class="special">=</span> <span class="identifier">AddendSize1</span><span class="special">;</span>
+ <span class="keyword">static</span> <span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">const</span> <span class="identifier">addend2_size</span> <span class="special">=</span> <span class="identifier">AddendSize2</span><span class="special">;</span>
+ <span class="keyword">static</span> <span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">const</span> <span class="identifier">sum_size</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">static_unsigned_max</span><span class="special"><</span><span class="identifier">AddendSize1</span><span class="special">,</span> <span class="identifier">AddendSize2</span><span class="special">>::</span><span class="identifier">value</span> <span class="special">+</span> <span class="number">1</span><span class="special">;</span>
+
+ <span class="keyword">typedef</span> <span class="keyword">int</span> <span class="identifier">addend1_type</span><span class="special">[</span> <span class="identifier">addend1_size</span> <span class="special">];</span>
+ <span class="keyword">typedef</span> <span class="keyword">int</span> <span class="identifier">addend2_type</span><span class="special">[</span> <span class="identifier">addend2_size</span> <span class="special">];</span>
+ <span class="keyword">typedef</span> <span class="keyword">int</span> <span class="identifier">sum_type</span><span class="special">[</span> <span class="identifier">sum_size</span> <span class="special">];</span>
+
+ <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">&</span><span class="identifier">a1</span><span class="special">,</span> <span class="identifier">addend2_type</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">a2</span><span class="special">,</span> <span class="identifier">sum_type</span> <span class="special">&</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="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="identifier">adder</span><span class="special"><</span><span class="number">3</span><span class="special">,</span><span class="number">2</span><span class="special">></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>
+</pre>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.minmax.demonstration_program"></a><a class="link" href="minmax.html#boost_integer.minmax.demonstration_program" title="Demonstration Program">Demonstration
+ Program</a>
+</h3></div></div></div>
+<p>
+ The program <a href="../../../test/static_min_max_test.cpp" target="_top">static_min_max_test.cpp</a>
+ is a simplistic demonstration of various comparisons using the compile-time
+ extrema class templates.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.minmax.rationale"></a><a class="link" href="minmax.html#boost_integer.minmax.rationale" title="Rationale">Rationale</a>
+</h3></div></div></div>
+<p>
+ Sometimes the minimum or maximum of several values needs to be found for
+ later compile-time processing, <span class="emphasis"><em>e.g.</em></span> for a bound for
+ another class template.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.minmax.credits"></a><a class="link" href="minmax.html#boost_integer.minmax.credits" title="Credits">Credits</a>
+</h3></div></div></div>
+<p>
+ The author of the Boost compile-time extrema class templates is <a href="http://www.boost.org/people/daryle_walker.html" target="_top">Daryle
+ Walker</a>.
+ </p>
+</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 © 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>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="log2.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="history.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/doc/html/boost_integer/traits.html b/doc/html/boost_integer/traits.html
new file mode 100644
index 0000000..76987ad
--- /dev/null
+++ b/doc/html/boost_integer/traits.html
@@ -0,0 +1,215 @@
+<html>
+<head>
+<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.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="integer.html" title="Integer Type Selection">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</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="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>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="traits.html#boost_integer.traits.motivation">Motivation</a></span></dt>
+<dt><span class="section"><a href="traits.html#boost_integer.traits.synopsis">Synopsis</a></span></dt>
+<dt><span class="section"><a href="traits.html#boost_integer.traits.description">Description</a></span></dt>
+<dt><span class="section"><a href="traits.html#boost_integer.traits.test_program">Test Program</a></span></dt>
+<dt><span class="section"><a href="traits.html#boost_integer.traits.acknowledgements">Acknowledgements</a></span></dt>
+</dl></div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.traits.motivation"></a><a class="link" href="traits.html#boost_integer.traits.motivation" title="Motivation">Motivation</a>
+</h3></div></div></div>
+<p>
+ The C++ Standard Library <limits> header supplies a class template
+ <code class="computeroutput"><span class="identifier">numeric_limits</span><span class="special"><></span></code>
+ with specializations for each fundamental type.
+ </p>
+<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"><></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>
+<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
+ constant expressions.
+ </p>
+<p>
+ The template class <code class="literal">integer_traits</code> addresses this problem.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.traits.synopsis"></a><a class="link" href="traits.html#boost_integer.traits.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="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
+ <span class="keyword">class</span> <span class="identifier">integer_traits</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span>
+ <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="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>
+</pre>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.traits.description"></a><a class="link" href="traits.html#boost_integer.traits.description" title="Description">Description</a>
+</h3></div></div></div>
+<p>
+ Template class <code class="literal">integer_traits</code> is derived from <code class="literal">std::numeric_limits</code>.
+ The primary specialization adds the single <code class="literal">bool</code> member
+ <code class="literal">is_integral</code> with the compile-time constant value <code class="literal">false</code>.
+ However, for all integral types <code class="literal">T</code> (std::3.9.1/7 [basic.fundamental]),
+ there are specializations provided with the following compile-time constants
+ defined:
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ member
+ </p>
+ </th>
+<th>
+ <p>
+ type
+ </p>
+ </th>
+<th>
+ <p>
+ value
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ <code class="literal">is_integral</code>
+ </p>
+ </td>
+<td>
+ <p>
+ bool
+ </p>
+ </td>
+<td>
+ <p>
+ <code class="literal">true</code>
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">const_min</code>
+ </p>
+ </td>
+<td>
+ <p>
+ <code class="literal">T</code>
+ </p>
+ </td>
+<td>
+ <p>
+ equivalent to <code class="literal">std::numeric_limits<T>::min()</code>
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal">const_max</code>
+ </p>
+ </td>
+<td>
+ <p>
+ <code class="literal">T</code>
+ </p>
+ </td>
+<td>
+ <p>
+ equivalent to <code class="literal">std::numeric_limits<T>::max()</code>
+ </p>
+ </td>
+</tr>
+</tbody>
+</table></div>
+<p>
+ Note: The <span class="emphasis"><em>is_integral</em></span> flag is provided, because a user-defined
+ integer class should specialize <code class="literal">std::numeric_limits<>::is_integer
+ = true</code>, while compile-time constants <code class="literal">const_min</code>
+ and <code class="literal">const_max</code> are not provided for that user-defined class,
+ unless boost::integer_traits is also specialized.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.traits.test_program"></a><a class="link" href="traits.html#boost_integer.traits.test_program" title="Test Program">Test Program</a>
+</h3></div></div></div>
+<p>
+ The program <code class="literal"><a href="../../../test/integer_traits_test.cpp" target="_top">integer_traits_test.cpp</a></code>
+ exercises the <code class="literal">integer_traits</code> class.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.traits.acknowledgements"></a><a class="link" href="traits.html#boost_integer.traits.acknowledgements" title="Acknowledgements">Acknowledgements</a>
+</h3></div></div></div>
+<p>
+ Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers discussed the integer
+ traits idea on the boost mailing list in August 1999.
+ </p>
+</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 © 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>
+</div></td>
+</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="integer.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/doc/html/index.html b/doc/html/index.html
new file mode 100644
index 0000000..040ad3e
--- /dev/null
+++ b/doc/html/index.html
@@ -0,0 +1,251 @@
+<html>
+<head>
+<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.77.1">
+<link rel="home" href="index.html" title="Boost.Integer">
+<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>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center"><a href="../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<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>
+<div><h2 class="title">
+<a name="boost_integer"></a>Boost.Integer</h2></div>
+<div><div class="authorgroup">
+<div class="author"><h3 class="author">
+<span class="firstname">Beman</span> <span class="surname">Dawes</span>
+</h3></div>
+<div class="author"><h3 class="author">
+<span class="firstname">Daryle</span> <span class="surname">Walker</span>
+</h3></div>
+<div class="author"><h3 class="author">
+<span class="firstname">Gennaro</span> <span class="surname">Prota</span>
+</h3></div>
+<div class="author"><h3 class="author">
+<span class="firstname">John</span> <span class="surname">Maddock</span>
+</h3></div>
+</div></div>
+<div><p class="copyright">Copyright © 2001-2009 Beman
+ Dawes, Daryle Walker, Gennaro Prota, John Maddock</p></div>
+<div><div class="legalnotice">
+<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>
+</div></div>
+</div>
+<hr>
+</div>
+<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/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/gcd_lcm.html">Greatest Common Divisor and Least
+ Common Multiple</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>
+</h2></div></div></div>
+<p>
+ 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 <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>
+<col>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Component
+ </p>
+ </th>
+<th>
+ <p>
+ Header
+ </p>
+ </th>
+<th>
+ <p>
+ Purpose
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ Forward Declarations.
+ </p>
+ </td>
+<td>
+ <p>
+ <code class="literal"><a href="../../../../boost/integer_fwd.hpp" target="_top"><boost/integer_fwd.hpp></a></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Forward declarations of classes and class templates - for use when
+ just the name of a class is needed.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <a class="link" href="boost_integer/traits.html" title="Integer Traits">Integer Traits</a>.
+ </p>
+ </td>
+<td>
+ <p>
+ <code class="literal"><a href="../../../../boost/integer_traits.hpp" target="_top"><boost/integer_traits.hpp></a></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Class template <code class="literal">boost::integer_traits</code>, derives
+ from <code class="literal">std::numeric_limits</code> and adds <code class="literal">const_min</code>
+ and <code class="literal">const_max</code> members.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <a class="link" href="boost_integer/integer.html" title="Integer Type Selection">Integer Type Selection</a>.
+ </p>
+ </td>
+<td>
+ <p>
+ <code class="literal"><a href="../../../../boost/integer.hpp" target="_top"><boost/integer.hpp></a></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Templates for integer type selection based on properties such as
+ maximum value or number of bits: Use to select the type of an integer
+ when some property such as maximum value or number of bits is known.
+ Useful for generic programming.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <a class="link" href="boost_integer/gcd_lcm.html" title="Greatest Common Divisor and Least Common Multiple">Greatest Common Divisor and
+ Least Common Multiple</a>.
+ </p>
+ </td>
+<td>
+ <p>
+ <code class="literal"><a href="../../../../boost/integer/common_factor_rt.hpp" target="_top"><boost/integer/common_factor_rt.hpp></a></code>
+ and <code class="literal"><a href="../../../../boost/integer/common_factor_ct.hpp" target="_top"><boost/integer/common_factor_ct.hpp></a></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Functions <code class="computeroutput"><span class="identifier">gcd</span></code> and
+ <code class="computeroutput"><span class="identifier">lcm</span></code> plus function
+ objects and compile time versions.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <a class="link" href="boost_integer/mask.html" title="Integer Masks">Integer Masks</a>.
+ </p>
+ </td>
+<td>
+ <p>
+ <code class="literal"><a href="../../../../boost/integer/integer_mask.hpp" target="_top"><boost/integer/integer_mask.hpp></a></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Templates for the selection of integer masks, single or lowest group,
+ based on the number of bits: Use to select a particular mask when
+ the bit position(s) are based on a compile-time variable. Useful
+ for generic programming.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <a class="link" href="boost_integer/log2.html" title="Compile Time log2 Calculation">Compile time log2 Calculation</a>.
+ </p>
+ </td>
+<td>
+ <p>
+ <code class="literal"><a href="../../../../boost/integer/static_log2.hpp" target="_top"><boost/integer/static_log2.hpp></a></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Template for finding the highest power of two in a number: Use to
+ find the bit-size/range based on a maximum value. Useful for generic
+ programming.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <a class="link" href="boost_integer/minmax.html" title="Compile time min/max calculation">Compile time min/max calculation</a>.
+ </p>
+ </td>
+<td>
+ <p>
+ <code class="literal"><a href="../../../../boost/integer/static_min_max.hpp" target="_top"><boost/integer/static_min_max.hpp></a></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Templates for finding the extrema of two numbers: Use to find a bound
+ based on a minimum or maximum value. Useful for generic programming.
+ </p>
+ </td>
+</tr>
+</tbody>
+</table></div>
+</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: April 24, 2017 at 17:49:59 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/traits.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
+</body>
+</html>
diff --git a/doc/integer.qbk b/doc/integer.qbk
new file mode 100644
index 0000000..75042f2
--- /dev/null
+++ b/doc/integer.qbk
@@ -0,0 +1,712 @@
+[article Boost.Integer
+ [quickbook 1.6]
+ [compatibility-mode 1.5]
+ [copyright 2001-2009 Beman Dawes, Daryle Walker, Gennaro Prota, John Maddock]
+ [purpose Integer Type Selection]
+ [license
+ 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])
+ ]
+ [authors [Dawes, Beman], [Walker, Daryle], [Prota, Gennaro], [Maddock, John]]
+ [/last-revision $Date: 2008-02-21 12:58:15 +0000 (Thu, 21 Feb 2008) $]
+]
+
+[template super[x]'''<superscript>'''[x]'''</superscript>''']
+
+[section:overview Overview]
+
+Boost.Integer provides integer type support, particularly helpful in generic programming.
+It provides the means to select an integer type based upon its properties, like the number of bits or
+the maximum supported value, as well as compile-time bit mask selection. There is a derivative of
+std::numeric_limits that provides integral constant expressions for `min` and `max`.
+Finally, it provides two compile-time algorithms: determining the highest power of two in a
+compile-time value; and computing min and max of constant expressions.
+
+[table
+ [[Component][Header][Purpose]]
+ [
+ [Forward Declarations.]
+ [[^[@../../../../boost/integer_fwd.hpp <boost/integer_fwd.hpp>]]]
+ [Forward declarations of classes and class templates - for use when just the name of a class is needed.]
+ ]
+ [
+ [[link boost_integer.traits Integer Traits].]
+ [[^[@../../../../boost/integer_traits.hpp <boost/integer_traits.hpp>]]]
+ [Class template [^boost::integer_traits], derives from [^std::numeric_limits] and adds [^const_min] and [^const_max] members.]
+ ]
+ [
+ [[link boost_integer.integer Integer Type Selection].]
+ [[^[@../../../../boost/integer.hpp <boost/integer.hpp>]]]
+ [Templates for integer type selection based on properties such as maximum value or number of bits:
+ Use to select the type of an integer when some property such as maximum value or number of bits is known.
+ Useful for generic programming. ]
+ ]
+ [
+ [[link boost_integer.gcd_lcm Greatest Common Divisor and Least Common Multiple].]
+ [[^[@../../../../boost/integer/common_factor_rt.hpp <boost/integer/common_factor_rt.hpp>]] and [^[@../../../../boost/integer/common_factor_ct.hpp <boost/integer/common_factor_ct.hpp>]]]
+ [Functions `gcd` and `lcm` plus function objects and compile time versions.]
+ ]
+ [
+ [[link boost_integer.mask Integer Masks].]
+ [[^[@../../../../boost/integer/integer_mask.hpp <boost/integer/integer_mask.hpp>]]]
+ [Templates for the selection of integer masks, single or lowest group, based on the number of bits:
+ Use to select a particular mask when the bit position(s) are based on a compile-time variable. Useful for generic programming. ]
+ ]
+ [
+ [[link boost_integer.log2 Compile time log2 Calculation].]
+ [[^[@../../../../boost/integer/static_log2.hpp <boost/integer/static_log2.hpp>]]]
+ [Template for finding the highest power of two in a number:
+ Use to find the bit-size/range based on a maximum value. Useful for generic programming. ]
+ ]
+ [
+ [[link boost_integer.minmax Compile time min/max calculation].]
+ [[^[@../../../../boost/integer/static_min_max.hpp <boost/integer/static_min_max.hpp>]]]
+ [Templates for finding the extrema of two numbers:
+ Use to find a bound based on a minimum or maximum value. Useful for generic programming. ]
+ ]
+]
+
+[endsect]
+
+[section:traits Integer Traits]
+
+[section Motivation]
+
+The C++ Standard Library <limits> header supplies a class template `numeric_limits<>` with specializations for each fundamental type.
+
+For integer types, the interesting members of `std::numeric_limits<>` are:
+
+ static const bool is_specialized; // Will be true for integer types.
+ static T min() throw(); // Smallest representable value.
+ static T max() throw(); // Largest representable value.
+ static const int digits; // For integers, the number of value bits.
+ static const int digits10; // The number of base 10 digits that can be represented.
+ static const bool is_signed; // True if the type is signed.
+ static const bool is_integer; // Will be true for all integer types.
+
+For many uses, these are sufficient.
+But min() and max() are problematical because they are not constant expressions (std::5.19),
+yet some usages require constant expressions.
+
+The template class [^integer_traits] addresses this problem.
+
+[endsect]
+
+[section Synopsis]
+
+ namespace boost {
+ template<class T>
+ class integer_traits : public std::numeric_limits<T>
+ {
+ public:
+ static const bool is_integral = false;
+ //
+ // These members are defined only if T is a built-in
+ // integal type:
+ //
+ static const T const_min = ``['implementation-defined]``;
+ static const T const_max = ``['implementation-defined]``;
+ };
+ }
+
+[endsect]
+
+[section Description]
+
+Template class [^integer_traits] is derived from [^std::numeric_limits]. The primary specialization adds the single
+[^bool] member [^is_integral] with the compile-time constant value [^false].
+However, for all integral types [^T] (std::3.9.1/7 [basic.fundamental]), there are specializations
+provided with the following compile-time constants defined:
+
+[table
+ [[member][type][value]]
+ [[[^is_integral]][bool][[^true]]]
+ [[[^const_min]][[^T]][equivalent to [^std::numeric_limits<T>::min()]]]
+ [[[^const_max]][[^T]][equivalent to [^std::numeric_limits<T>::max()]]]
+]
+
+Note: The /is_integral/ flag is provided, because a user-defined integer class should specialize
+[^std::numeric_limits<>::is_integer = true], while compile-time constants
+[^const_min] and [^const_max] are not provided for that user-defined class, unless boost::integer_traits is also specialized.
+
+[endsect]
+
+[section Test Program]
+
+The program [^[@../../test/integer_traits_test.cpp integer_traits_test.cpp]] exercises the [^integer_traits] class.
+
+[endsect]
+
+[section Acknowledgements]
+
+Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers discussed the integer traits idea on the boost mailing list in August 1999.
+
+[endsect]
+[endsect]
+
+[section:integer Integer Type Selection]
+
+The [@../../../../boost/integer.hpp <boost/integer.hpp>] type selection templates allow
+integer types to be selected based on desired characteristics such as number of bits or maximum value.
+This facility is particularly useful for solving generic programming problems.
+
+[section:synopsis Synopsis]
+
+ namespace boost
+ {
+ // fast integers from least integers
+ template<typename LeastInt>
+ struct int_fast_t
+ {
+ typedef ``['implementation-defined-type]`` type;
+ };
+
+ // signed
+ template<int Bits>
+ struct int_t
+ {
+ /* Member exact may or may not be defined depending upon Bits */
+ typedef ``['implementation-defined-type]`` exact;
+ typedef ``['implementation-defined-type]`` least;
+ typedef int_fast_t<least>::fast fast;
+ };
+
+ // unsigned
+ template<int Bits>
+ struct uint_t
+ {
+ /* Member exact may or may not be defined depending upon Bits */
+ typedef ``['implementation-defined-type]`` exact;
+ typedef ``['implementation-defined-type]`` least;
+ typedef int_fast_t<least>::fast fast;
+ };
+
+ // signed
+ template<long long MaxValue>
+ struct int_max_value_t
+ {
+ typedef ``['implementation-defined-type]`` least;
+ typedef int_fast_t<least>::fast fast;
+ };
+
+ template<long long MinValue>
+ struct int_min_value_t
+ {
+ typedef ``['implementation-defined-type]`` least;
+ typedef int_fast_t<least>::fast fast;
+ };
+
+ // unsigned
+ template<unsigned long long Value>
+ struct uint_value_t
+ {
+ typedef ``['implementation-defined-type]`` least;
+ typedef int_fast_t<least>::fast fast;
+ };
+ } // namespace boost
+
+[endsect]
+
+[section:easiest Easiest-to-Manipulate Types]
+
+The [^int_fast_t] class template maps its input type to the next-largest type that the processor
+can manipulate the easiest, or to itself if the input type is already an easy-to-manipulate type.
+For instance, processing a bunch of [^char] objects may go faster if they were converted to [^int] objects before processing.
+The input type, passed as the only template parameter, must be a built-in integral type, except [^bool].
+Unsigned integral types can be used, as well as signed integral types.
+The output type is given as the nested type [^fast].
+
+[*Implementation Notes:]
+By default, the output type is identical to the input type. Eventually, this code's implementation should
+be customized for each platform to give accurate mappings between the built-in types and the easiest-to-manipulate
+built-in types. Also, there is no guarantee that the output type actually is easier to manipulate than the input type.
+
+[endsect]
+
+[section:sized Sized Types]
+
+The [^int_t], [^uint_t], [^int_max_value_t], [^int_min_value_t], and [^uint_value_t] class templates find
+the most appropiate built-in integral type for the given template parameter. This type is given by the
+nested type [^least]. The easiest-to-manipulate version of that type is given by the nested type [^fast].
+The following table describes each template's criteria.
+
+[table Criteria for the Sized Type Class Templates
+ [
+ [Class Template][Template Parameter Mapping]
+ ]
+ [
+ [[^boost::int_t<N>::least]]
+ [The smallest, built-in, signed integral type with at least /N/ bits, including the sign bit.
+ The parameter should be a positive number. A compile-time error results if the parameter is
+ larger than the number of bits in the largest integer type.]
+ ]
+ [
+ [[^boost::int_t<N>::fast]]
+ [The easiest-to-manipulate, built-in, signed integral type with at least /N/ bits, including the sign bit.
+ The parameter should be a positive number. A compile-time error results if the parameter is
+ larger than the number of bits in the largest integer type.]
+ ]
+ [
+ [[^boost::int_t<N>::exact]]
+ [A built-in, signed integral type with exactly /N/ bits, including the sign bit.
+ The parameter should be a positive number. Note that the member /exact/ is defined
+ [*only] if there exists a type with exactly /N/ bits.]
+ ]
+ [
+ [[^boost::uint_t<N>::least]]
+ [The smallest, built-in, unsigned integral type with at least /N/ bits.
+ The parameter should be a positive number. A compile-time error results if the
+ parameter is larger than the number of bits in the largest integer type.]
+ ]
+ [
+ [[^boost::uint_t<N>::fast]]
+ [The easiest-to-manipulate, built-in, unsigned integral type with at least /N/ bits.
+ The parameter should be a positive number. A compile-time error results if the
+ parameter is larger than the number of bits in the largest integer type.]
+ ]
+ [
+ [[^boost::uint_t<N>::exact]]
+ [A built-in, unsigned integral type with exactly /N/ bits.
+ The parameter should be a positive number. A compile-time error results if the
+ parameter is larger than the number of bits in the largest integer type.
+ Note that the member /exact/ is defined
+ [*only] if there exists a type with exactly N bits.]
+ ]
+ [
+ [[^boost::int_max_value_t<V>::last]]
+ [The smallest, built-in, signed integral type that can hold all the values in the inclusive range ['0 - V].
+ The parameter should be a positive number.]
+ ]
+ [
+ [[^boost::int_max_value_t<V>::fast]]
+ [The easiest-to-manipulate, built-in, signed integral type that can hold all the values in the inclusive range ['0 - V].
+ The parameter should be a positive number.]
+ ]
+ [
+ [[^boost::int_min_value_t<V>::least]]
+ [The smallest, built-in, signed integral type that can hold all the values in the inclusive range ['V - 0].
+ The parameter should be a negative number.]
+ ]
+ [
+ [[^boost::int_min_value_t<V>::fast]]
+ [The easiest-to-manipulate, built-in, signed integral type that can hold all the values in the inclusive range ['V - 0].
+ The parameter should be a negative number.]
+ ]
+ [
+ [[^boost::uint_value_t<V>::least]]
+ [The smallest, built-in, unsigned integral type that can hold all positive values
+ up to and including /V/. The parameter should be a positive number.]
+ ]
+ [
+ [[^boost::uint_value_t<V>::fast]]
+ [The easiest-to-manipulate, built-in, unsigned integral type that can hold all positive values
+ up to and including /V/. The parameter should be a positive number.]
+ ]
+]
+
+[endsect]
+
+[section Example]
+
+ #include <boost/integer.hpp>
+
+ //...
+
+ int main()
+ {
+ boost::int_t<24>::least my_var; // my_var has at least 24-bits
+ //...
+ // This one is guarenteed not to be truncated:
+ boost::int_max_value_t<1000>::least my1000 = 1000;
+ //...
+ // This one is guarenteed not to be truncated, and as fast
+ // to manipulate as possible, its size may be greater than
+ // that of my1000:
+ boost::int_max_value_t<1000>::fast my_fast1000 = 1000;
+ }
+
+[endsect]
+
+[section Demonstration Program]
+
+The program [@../../test/integer_test.cpp integer_test.cpp] is a simplistic demonstration of the results from instantiating
+various examples of the sized type class templates.
+
+[endsect]
+
+[section Rationale]
+
+The rationale for the design of the templates in this header includes:
+
+* Avoid recursion because of concern about C++'s limited guaranteed recursion depth (17).
+* Avoid macros on general principles.
+* Try to keep the design as simple as possible.
+
+[endsect]
+
+[section Alternative]
+
+If the number of bits required is known beforehand, it may be more appropriate to use the types supplied
+in [@../../../../boost/cstdint.hpp <boost/cstdint.hpp>].
+
+[endsect]
+
+[section Credits]
+
+The author of most of the Boost integer type choosing templates is
+[@http://www.boost.org/people/beman_dawes.html Beman Dawes].
+He gives thanks to Valentin Bonnard and [@http://www.boost.org/people/kevlin_henney.htm Kevlin Henney]
+for sharing their designs for similar templates.
+[@http://www.boost.org/people/daryle_walker.html Daryle Walker] designed the value-based sized templates.
+
+[endsect]
+[endsect]
+
+[include gcd/math-gcd.qbk]
+
+
+[section:mask Integer Masks]
+
+[section Overview]
+
+The class templates in [@../../../../boost/integer/integer_mask.hpp <boost/integer/integer_mask.hpp>]
+provide bit masks for a certain bit position or a contiguous-bit pack of a certain size.
+The types of the masking constants come from the [link boost_integer.integer integer type selection templates] header.
+
+[endsect]
+
+[section Synopsis]
+
+ #include <cstddef> // for std::size_t
+
+ namespace boost
+ {
+
+ template <std::size_t Bit>
+ struct high_bit_mask_t
+ {
+ typedef ``['implementation-defined-type]`` least;
+ typedef ``['implementation-defined-type]`` fast;
+
+ static const least high_bit = ``['implementation-defined]``;
+ static const fast high_bit_fast = ``['implementation-defined]``;
+
+ static const std::size_t bit_position = Bit;
+ };
+
+ template <std::size_t Bits>
+ struct low_bits_mask_t
+ {
+ typedef ``['implementation-defined-type]`` least;
+ typedef ``['implementation-defined-type]`` fast;
+
+ static const least sig_bits = ``['implementation-defined]``;
+ static const fast sig_bits_fast = ``['implementation-defined]``;
+
+ static const std::size_t bit_count = Bits;
+ };
+
+ // Specializations for low_bits_mask_t exist for certain bit counts.
+
+ } // namespace boost
+
+[endsect]
+
+[section Single Bit-Mask Class Template]
+
+The [^boost::high_bit_mask_t] class template provides constants for bit masks representing the bit at a
+certain position. The masks are equivalent to the value 2[super Bit], where [^Bit] is the template parameter.
+The bit position must be a nonnegative number from zero to ['Max], where Max is one less than the
+number of bits supported by the largest unsigned built-in integral type. The following table describes
+the members of an instantiation of [^high_bit_mask_t].
+
+[table Members of the `boost::high_bit_mask_t` Class Template
+ [[Member][Meaning]]
+ [[[^least]][The smallest, unsigned, built-in type that supports the given bit position.]]
+ [[[^fast]][The easiest-to-manipulate analog of [^least].]]
+ [[[^high_bit]][A [^least] constant of the value 2[super Bit].]]
+ [[[^high_bit_fast]][A [^fast] analog of [^high_bit].]]
+ [[[^bit_position]][The value of the template parameter, in case its needed from a renamed instantiation of the class template.]]
+]
+
+[endsect]
+
+[section Group Bit-Mask Class Template]
+
+The [^boost::low_bits_mask_t] class template provides constants for bit masks
+equivalent to the value (2[super Bits] - 1), where [^Bits] is the template parameter.
+The parameter [^Bits] must be a non-negative integer from
+zero to ['Max], where Max is the number of bits supported by the largest, unsigned, built-in integral type.
+The following table describes the members of [^low_bits_mask_t].
+
+[table Members of the [^boost::low_bits_mask_t] Class Template
+[[Member][Meaning]]
+[[[^least]][The smallest, unsigned built-in type that supports the given bit count.]]
+[[[^fast]][The easiest-to-manipulate analog of [^least].]]
+[[[^sig_bits]][A [^least] constant of the desired bit-masking value.]]
+[[[^sig_bits_fast]][A [^fast] analog of [^sig_bits].]]
+[[[^bit_count]][The value of the template parameter, in case its needed from a renamed instantiation of the class template.]]
+]
+
+[endsect]
+
+[section Implementation Notes]
+
+When [^Bits] is the exact size of a built-in unsigned type, the implementation has to change to
+prevent undefined behavior. Therefore, there are specializations of [^low_bits_mask_t] at those bit counts.
+
+[endsect]
+
+[section Example]
+
+ #include <boost/integer/integer_mask.hpp>
+
+ //...
+
+ int main()
+ {
+ typedef boost::high_bit_mask_t<29> mask1_type;
+ typedef boost::low_bits_mask_t<15> mask2_type;
+
+ mask1_type::least my_var1;
+ mask2_type::fast my_var2;
+ //...
+
+ my_var1 |= mask1_type::high_bit;
+ my_var2 &= mask2_type::sig_bits_fast;
+
+ //...
+ }
+
+[endsect]
+
+[section Demonstration Program]
+
+The program [@../../test/integer_mask_test.cpp integer_mask_test.cpp] is a simplistic demonstration of the
+results from instantiating various examples of the bit mask class templates.
+
+[endsect]
+
+[section Rationale]
+
+The class templates in this header are an extension of the [link boost_integer.integer integer type selection class templates].
+The new class templates provide the same sized types, but also convenient masks to use when extracting the
+highest or all the significant bits when the containing built-in type contains more bits.
+This prevents contamination of values by the higher, unused bits.
+
+[endsect]
+
+[section Credits]
+
+The author of the Boost bit mask class templates is [@http://www.boost.org/people/daryle_walker.html Daryle Walker].
+
+[endsect]
+[endsect]
+
+[section:log2 Compile Time log2 Calculation]
+
+The class template in [@../../../../boost/integer/static_log2.hpp <boost/integer/static_log2.hpp>]
+determines the position of the highest bit in a given value. This facility is useful for solving generic programming problems.
+
+[section Synopsis]
+
+ namespace boost
+ {
+
+ typedef ``['implementation-defined]`` static_log2_argument_type;
+ typedef ``['implementation-defined]`` static_log2_result_type;
+
+ template <static_log2_argument_type arg>
+ struct static_log2
+ {
+ static const static_log2_result_type value = ``['implementation-defined]``;
+ };
+
+
+ template < >
+ struct static_log2< 0 >
+ {
+ // The logarithm of zero is undefined.
+ };
+
+
+ } // namespace boost
+
+[endsect]
+
+[section Usage]
+
+The [^boost::static_log2] class template takes one template parameter, a value of type
+[^static_log2_argument_type]. The template only defines one member, [^value], which gives the
+truncated, base-two logarithm of the template argument.
+
+Since the logarithm of zero, for any base, is undefined, there is a specialization of [^static_log2]
+for a template argument of zero. This specialization has no members, so an attempt to use the base-two
+logarithm of zero results in a compile-time error.
+
+Note:
+
+* [^static_log2_argument_type] is an ['unsigned integer type] (C++ standard, 3.9.1p3).
+* [^static_log2_result_type] is an ['integer type] (C++ standard, 3.9.1p7).
+
+[endsect]
+
+[section Demonstration Program]
+
+The program [@../../test/static_log2_test.cpp static_log2_test.cpp] is a simplistic
+demonstration of the results from instantiating various examples of the binary logarithm class template.
+
+[endsect]
+
+[section Rationale]
+
+The base-two (binary) logarithm, abbreviated lb, function is occasionally used to give order-estimates
+of computer algorithms. The truncated logarithm can be considered the highest power-of-two in a value,
+which corresponds to the value's highest set bit (for binary integers). Sometimes the highest-bit position
+could be used in generic programming, which requires the position to be available statically (['i.e.] at compile-time).
+
+[endsect]
+
+[section Credits]
+
+The original version of the Boost binary logarithm class template was
+written by [@http://www.boost.org/people/daryle_walker.html Daryle Walker] and then
+enhanced by Giovanni Bajo with support for compilers without partial template specialization.
+The current version was suggested, together with a reference implementation, by Vesa Karvonen.
+Gennaro Prota wrote the actual source file.
+
+[endsect]
+[endsect]
+
+[section:minmax Compile time min/max calculation]
+
+The class templates in [@../../../../boost/integer/static_min_max.hpp <boost/integer/static_min_max.hpp>]
+provide a compile-time evaluation of the minimum or maximum of two integers. These facilities are useful
+for generic programming problems.
+
+[section Synopsis]
+
+ namespace boost
+ {
+
+ typedef ``['implementation-defined]`` static_min_max_signed_type;
+ typedef ``['implementation-defined]`` static_min_max_unsigned_type;
+
+ template <static_min_max_signed_type Value1, static_min_max_signed_type Value2 >
+ struct static_signed_min;
+
+ template <static_min_max_signed_type Value1, static_min_max_signed_type Value2>
+ struct static_signed_max;
+
+ template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
+ struct static_unsigned_min;
+
+ template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
+ struct static_unsigned_max;
+
+ }
+
+[endsect]
+
+[section Usage]
+
+The four class templates provide the combinations for finding the minimum or maximum of two [^signed] or
+[^unsigned] ([^long]) parameters, /Value1/ and /Value2/, at compile-time. Each template has a single static data member,
+[^value], which is set to the respective minimum or maximum of the template's parameters.
+
+[endsect]
+
+[section Example]
+
+ #include <boost/integer/static_min_max.hpp>
+
+ template < unsigned long AddendSize1, unsigned long AddendSize2 >
+ class adder
+ {
+ public:
+ static unsigned long const addend1_size = AddendSize1;
+ static unsigned long const addend2_size = AddendSize2;
+ static unsigned long const sum_size = boost::static_unsigned_max<AddendSize1, AddendSize2>::value + 1;
+
+ typedef int addend1_type[ addend1_size ];
+ typedef int addend2_type[ addend2_size ];
+ typedef int sum_type[ sum_size ];
+
+ void operator ()( addend1_type const &a1, addend2_type const &a2, sum_type &s ) const;
+ };
+
+ //...
+
+ int main()
+ {
+ int const a1[] = { 0, 4, 3 }; // 340
+ int const a2[] = { 9, 8 }; // 89
+ int s[ 4 ];
+ adder<3,2> obj;
+
+ obj( a1, a2, s ); // 's' should be 429 or { 9, 2, 4, 0 }
+ //...
+ }
+
+[endsect]
+
+[section Demonstration Program]
+
+The program [@../../test/static_min_max_test.cpp static_min_max_test.cpp] is a simplistic demonstration of
+various comparisons using the compile-time extrema class templates.
+
+[endsect]
+
+[section Rationale]
+
+Sometimes the minimum or maximum of several values needs to be found for later compile-time processing,
+['e.g.] for a bound for another class template.
+
+[endsect]
+
+[section Credits]
+
+The author of the Boost compile-time extrema class templates is [@http://www.boost.org/people/daryle_walker.html Daryle Walker].
+
+[endsect]
+[endsect]
+
+[section:history History]
+
+[h4 1.56.0]
+
+* Moved `<boost/cstdint.hpp>` into [@boost:/libs/config/index.html
+ Boost.Config].
+
+[h4 1.42.0]
+
+* Reverted Trunk to release branch state (i.e. a "known good state").
+* Fixed issues: [@https://svn.boost.org/trac/boost/ticket/653 653],
+[@https://svn.boost.org/trac/boost/ticket/3084 3084],
+[@https://svn.boost.org/trac/boost/ticket/3177 3177],
+[@https://svn.boost.org/trac/boost/ticket/3180 3180],
+[@https://svn.boost.org/trac/boost/ticket/3548 3568],
+[@https://svn.boost.org/trac/boost/ticket/3657 3657],
+[@https://svn.boost.org/trac/boost/ticket/2134 2134].
+* Added long long support to [^boost::static_log2], [^boost::static_signed_min], [^boost::static_signed_max],
+[^boost::static_unsigned_min][^boost::static_unsigned_max], when available.
+* The argument type and the result type of [^boost::static_signed_min] etc are now typedef'd.
+Formerly, they were hardcoded as [^unsigned long] and [^int] respectively. Please, use the
+provided typedefs in new code (and update old code as soon as possible).
+
+[h4 1.32.0]
+
+* The argument type and the result type of [^boost::static_log2] are now typedef'd.
+Formerly, they were hardcoded as [^unsigned long] and [^int] respectively. Please, use the
+provided typedefs in new code (and update old code as soon as possible).
+
+[endsect]
+
+[section:cstdint Removed from library: Standard Integer Types]
+
+The [@boost:/libs/config/doc/html/boost_config/cstdint.html Boost.Config] module provides
+the typedefs useful for writing portable code that requires certain
+integer widths.
+
+[endsect]
diff --git a/include/boost/integer.hpp b/include/boost/integer.hpp
new file mode 100644
index 0000000..9fa0019
--- /dev/null
+++ b/include/boost/integer.hpp
@@ -0,0 +1,262 @@
+// boost integer.hpp header file -------------------------------------------//
+
+// Copyright Beman Dawes and Daryle Walker 1999. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/integer for documentation.
+
+// Revision History
+// 22 Sep 01 Added value-based integer templates. (Daryle Walker)
+// 01 Apr 01 Modified to use new <boost/limits.hpp> header. (John Maddock)
+// 30 Jul 00 Add typename syntax fix (Jens Maurer)
+// 28 Aug 99 Initial version
+
+#ifndef BOOST_INTEGER_HPP
+#define BOOST_INTEGER_HPP
+
+#include <boost/integer_fwd.hpp> // self include
+
+#include <boost/integer_traits.hpp> // for boost::::boost::integer_traits
+#include <boost/limits.hpp> // for ::std::numeric_limits
+#include <boost/cstdint.hpp> // for boost::int64_t and BOOST_NO_INTEGRAL_INT64_T
+#include <boost/static_assert.hpp>
+
+//
+// We simply cannot include this header on gcc without getting copious warnings of the kind:
+//
+// boost/integer.hpp:77:30: warning: use of C99 long long integer constant
+//
+// And yet there is no other reasonable implementation, so we declare this a system header
+// to suppress these warnings.
+//
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#pragma GCC system_header
+#endif
+
+namespace boost
+{
+
+ // Helper templates ------------------------------------------------------//
+
+ // fast integers from least integers
+ // int_fast_t<> works correctly for unsigned too, in spite of the name.
+ template< typename LeastInt >
+ struct int_fast_t
+ {
+ typedef LeastInt fast;
+ typedef fast type;
+ }; // imps may specialize
+
+ namespace detail{
+
+ // convert category to type
+ template< int Category > struct int_least_helper {}; // default is empty
+ template< int Category > struct uint_least_helper {}; // default is empty
+
+ // specializatons: 1=long, 2=int, 3=short, 4=signed char,
+ // 6=unsigned long, 7=unsigned int, 8=unsigned short, 9=unsigned char
+ // no specializations for 0 and 5: requests for a type > long are in error
+#ifdef BOOST_HAS_LONG_LONG
+ template<> struct int_least_helper<1> { typedef boost::long_long_type least; };
+#elif defined(BOOST_HAS_MS_INT64)
+ template<> struct int_least_helper<1> { typedef __int64 least; };
+#endif
+ template<> struct int_least_helper<2> { typedef long least; };
+ template<> struct int_least_helper<3> { typedef int least; };
+ template<> struct int_least_helper<4> { typedef short least; };
+ template<> struct int_least_helper<5> { typedef signed char least; };
+#ifdef BOOST_HAS_LONG_LONG
+ template<> struct uint_least_helper<1> { typedef boost::ulong_long_type least; };
+#elif defined(BOOST_HAS_MS_INT64)
+ template<> struct uint_least_helper<1> { typedef unsigned __int64 least; };
+#endif
+ template<> struct uint_least_helper<2> { typedef unsigned long least; };
+ template<> struct uint_least_helper<3> { typedef unsigned int least; };
+ template<> struct uint_least_helper<4> { typedef unsigned short least; };
+ template<> struct uint_least_helper<5> { typedef unsigned char least; };
+
+ template <int Bits>
+ struct exact_signed_base_helper{};
+ template <int Bits>
+ struct exact_unsigned_base_helper{};
+
+ template <> struct exact_signed_base_helper<sizeof(signed char)* CHAR_BIT> { typedef signed char exact; };
+ template <> struct exact_unsigned_base_helper<sizeof(unsigned char)* CHAR_BIT> { typedef unsigned char exact; };
+#if USHRT_MAX != UCHAR_MAX
+ template <> struct exact_signed_base_helper<sizeof(short)* CHAR_BIT> { typedef short exact; };
+ template <> struct exact_unsigned_base_helper<sizeof(unsigned short)* CHAR_BIT> { typedef unsigned short exact; };
+#endif
+#if UINT_MAX != USHRT_MAX
+ template <> struct exact_signed_base_helper<sizeof(int)* CHAR_BIT> { typedef int exact; };
+ template <> struct exact_unsigned_base_helper<sizeof(unsigned int)* CHAR_BIT> { typedef unsigned int exact; };
+#endif
+#if ULONG_MAX != UINT_MAX && ( !defined __TI_COMPILER_VERSION__ || \
+ ( __TI_COMPILER_VERSION__ >= 7000000 && !defined __TI_40BIT_LONG__ ) )
+ template <> struct exact_signed_base_helper<sizeof(long)* CHAR_BIT> { typedef long exact; };
+ template <> struct exact_unsigned_base_helper<sizeof(unsigned long)* CHAR_BIT> { typedef unsigned long exact; };
+#endif
+#if defined(BOOST_HAS_LONG_LONG) &&\
+ ((defined(ULLONG_MAX) && (ULLONG_MAX != ULONG_MAX)) ||\
+ (defined(ULONG_LONG_MAX) && (ULONG_LONG_MAX != ULONG_MAX)) ||\
+ (defined(ULONGLONG_MAX) && (ULONGLONG_MAX != ULONG_MAX)) ||\
+ (defined(_ULLONG_MAX) && (_ULLONG_MAX != ULONG_MAX)))
+ template <> struct exact_signed_base_helper<sizeof(boost::long_long_type)* CHAR_BIT> { typedef boost::long_long_type exact; };
+ template <> struct exact_unsigned_base_helper<sizeof(boost::ulong_long_type)* CHAR_BIT> { typedef boost::ulong_long_type exact; };
+#endif
+
+
+ } // namespace detail
+
+ // integer templates specifying number of bits ---------------------------//
+
+ // signed
+ template< int Bits > // bits (including sign) required
+ struct int_t : public boost::detail::exact_signed_base_helper<Bits>
+ {
+ 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 <= (int)(sizeof(boost::long_long_type) * CHAR_BIT)) +
+#else
+ 1 +
+#endif
+ (Bits-1 <= ::std::numeric_limits<long>::digits) +
+ (Bits-1 <= ::std::numeric_limits<int>::digits) +
+ (Bits-1 <= ::std::numeric_limits<short>::digits) +
+ (Bits-1 <= ::std::numeric_limits<signed char>::digits)
+ >::least least;
+ typedef typename int_fast_t<least>::type fast;
+ };
+
+ // unsigned
+ template< int Bits > // bits required
+ 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 =
+ 6 +
+ (Bits <= ::std::numeric_limits<unsigned long>::digits) +
+ (Bits <= ::std::numeric_limits<unsigned int>::digits) +
+ (Bits <= ::std::numeric_limits<unsigned short>::digits) +
+ (Bits <= ::std::numeric_limits<unsigned char>::digits));
+ typedef typename detail::int_least_helper< ::boost::uint_t<Bits>::s>::least least;
+#else
+ typedef typename boost::detail::uint_least_helper
+ <
+#ifdef BOOST_HAS_LONG_LONG
+ (Bits <= (int)(sizeof(boost::long_long_type) * CHAR_BIT)) +
+#else
+ 1 +
+#endif
+ (Bits <= ::std::numeric_limits<unsigned long>::digits) +
+ (Bits <= ::std::numeric_limits<unsigned int>::digits) +
+ (Bits <= ::std::numeric_limits<unsigned short>::digits) +
+ (Bits <= ::std::numeric_limits<unsigned char>::digits)
+ >::least least;
+#endif
+ typedef typename int_fast_t<least>::type fast;
+ // int_fast_t<> works correctly for unsigned too, in spite of the name.
+ };
+
+ // integer templates specifying extreme value ----------------------------//
+
+ // signed
+#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
+ template< boost::long_long_type MaxValue > // maximum value to require support
+#else
+ template< long MaxValue > // maximum value to require support
+#endif
+ struct int_max_value_t
+ {
+ typedef typename boost::detail::int_least_helper
+ <
+#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
+ (MaxValue <= ::boost::integer_traits<boost::long_long_type>::const_max) +
+#else
+ 1 +
+#endif
+ (MaxValue <= ::boost::integer_traits<long>::const_max) +
+ (MaxValue <= ::boost::integer_traits<int>::const_max) +
+ (MaxValue <= ::boost::integer_traits<short>::const_max) +
+ (MaxValue <= ::boost::integer_traits<signed char>::const_max)
+ >::least least;
+ typedef typename int_fast_t<least>::type fast;
+ };
+
+#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
+ template< boost::long_long_type MinValue > // minimum value to require support
+#else
+ template< long MinValue > // minimum value to require support
+#endif
+ struct int_min_value_t
+ {
+ typedef typename boost::detail::int_least_helper
+ <
+#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
+ (MinValue >= ::boost::integer_traits<boost::long_long_type>::const_min) +
+#else
+ 1 +
+#endif
+ (MinValue >= ::boost::integer_traits<long>::const_min) +
+ (MinValue >= ::boost::integer_traits<int>::const_min) +
+ (MinValue >= ::boost::integer_traits<short>::const_min) +
+ (MinValue >= ::boost::integer_traits<signed char>::const_min)
+ >::least least;
+ typedef typename int_fast_t<least>::type fast;
+ };
+
+ // unsigned
+#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
+ template< boost::ulong_long_type MaxValue > // minimum value to require support
+#else
+ template< unsigned long MaxValue > // minimum value to require support
+#endif
+ struct uint_value_t
+ {
+#if (defined(__BORLANDC__) || defined(__CODEGEAR__))
+ // It's really not clear why this workaround should be needed... shrug I guess! JM
+#if defined(BOOST_NO_INTEGRAL_INT64_T)
+ BOOST_STATIC_CONSTANT(unsigned, which =
+ 1 +
+ (MaxValue <= ::boost::integer_traits<unsigned long>::const_max) +
+ (MaxValue <= ::boost::integer_traits<unsigned int>::const_max) +
+ (MaxValue <= ::boost::integer_traits<unsigned short>::const_max) +
+ (MaxValue <= ::boost::integer_traits<unsigned char>::const_max));
+ typedef typename detail::int_least_helper< ::boost::uint_value_t<MaxValue>::which>::least least;
+#else // BOOST_NO_INTEGRAL_INT64_T
+ BOOST_STATIC_CONSTANT(unsigned, which =
+ 1 +
+ (MaxValue <= ::boost::integer_traits<boost::ulong_long_type>::const_max) +
+ (MaxValue <= ::boost::integer_traits<unsigned long>::const_max) +
+ (MaxValue <= ::boost::integer_traits<unsigned int>::const_max) +
+ (MaxValue <= ::boost::integer_traits<unsigned short>::const_max) +
+ (MaxValue <= ::boost::integer_traits<unsigned char>::const_max));
+ typedef typename detail::uint_least_helper< ::boost::uint_value_t<MaxValue>::which>::least least;
+#endif // BOOST_NO_INTEGRAL_INT64_T
+#else
+ typedef typename boost::detail::uint_least_helper
+ <
+#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
+ (MaxValue <= ::boost::integer_traits<boost::ulong_long_type>::const_max) +
+#else
+ 1 +
+#endif
+ (MaxValue <= ::boost::integer_traits<unsigned long>::const_max) +
+ (MaxValue <= ::boost::integer_traits<unsigned int>::const_max) +
+ (MaxValue <= ::boost::integer_traits<unsigned short>::const_max) +
+ (MaxValue <= ::boost::integer_traits<unsigned char>::const_max)
+ >::least least;
+#endif
+ typedef typename int_fast_t<least>::type fast;
+ };
+
+
+} // namespace boost
+
+#endif // BOOST_INTEGER_HPP
diff --git a/include/boost/integer/common_factor.hpp b/include/boost/integer/common_factor.hpp
new file mode 100644
index 0000000..fab9199
--- /dev/null
+++ b/include/boost/integer/common_factor.hpp
@@ -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
diff --git a/include/boost/integer/common_factor_ct.hpp b/include/boost/integer/common_factor_ct.hpp
new file mode 100644
index 0000000..0671d16
--- /dev/null
+++ b/include/boost/integer/common_factor_ct.hpp
@@ -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
diff --git a/include/boost/integer/common_factor_rt.hpp b/include/boost/integer/common_factor_rt.hpp
new file mode 100644
index 0000000..341b316
--- /dev/null
+++ b/include/boost/integer/common_factor_rt.hpp
@@ -0,0 +1,578 @@
+// (C) Copyright Jeremy William Murphy 2016.
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_INTEGER_COMMON_FACTOR_RT_HPP
+#define BOOST_INTEGER_COMMON_FACTOR_RT_HPP
+
+#include <boost/assert.hpp>
+#include <boost/core/enable_if.hpp>
+
+#include <boost/config.hpp> // for BOOST_NESTED_TEMPLATE, etc.
+#include <boost/limits.hpp> // for std::numeric_limits
+#include <climits> // for CHAR_MIN
+#include <boost/detail/workaround.hpp>
+#include <iterator>
+#include <algorithm>
+#include <limits>
+#ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS
+#include <type_traits>
+#endif
+#ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
+#include <functional>
+#endif
+
+#if ((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))
+#include <intrin.h>
+#endif
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4127 4244) // Conditional expression is constant
+#endif
+
+#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) && !defined(BOOST_NO_CXX11_NOEXCEPT)
+#define BOOST_GCD_NOEXCEPT(T) noexcept(std::is_arithmetic<T>::value)
+#else
+#define BOOST_GCD_NOEXCEPT(T)
+#endif
+
+namespace boost {
+
+ template <class I>
+ class rational;
+
+ namespace integer {
+
+ namespace gcd_detail{
+
+ //
+ // some helper functions which really should be constexpr already, but sadly aren't:
+ //
+#ifndef BOOST_NO_CXX14_CONSTEXPR
+ template <class T>
+ inline constexpr T constexpr_min(T const& a, T const& b) BOOST_GCD_NOEXCEPT(T)
+ {
+ return a < b ? a : b;
+ }
+ template <class T>
+ inline constexpr auto constexpr_swap(T&a, T& b) BOOST_GCD_NOEXCEPT(T) -> decltype(a.swap(b))
+ {
+ return a.swap(b);
+ }
+ template <class T, class U>
+ inline constexpr void constexpr_swap(T&a, U& b...) BOOST_GCD_NOEXCEPT(T)
+ {
+ T t(static_cast<T&&>(a));
+ a = static_cast<T&&>(b);
+ b = static_cast<T&&>(t);
+ }
+#else
+ template <class T>
+ inline T constexpr_min(T const& a, T const& b) BOOST_GCD_NOEXCEPT(T)
+ {
+ return a < b ? a : b;
+ }
+ template <class T>
+ inline void constexpr_swap(T&a, T& b) BOOST_GCD_NOEXCEPT(T)
+ {
+ using std::swap;
+ swap(a, b);
+ }
+#endif
+
+ template <class T, bool a =
+#ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS
+ std::is_unsigned<T>::value ||
+#endif
+ (std::numeric_limits<T>::is_specialized && !std::numeric_limits<T>::is_signed)>
+ struct gcd_traits_abs_defaults
+ {
+ inline static BOOST_CXX14_CONSTEXPR const T& abs(const T& val) BOOST_GCD_NOEXCEPT(T) { return val; }
+ };
+ template <class T>
+ struct gcd_traits_abs_defaults<T, false>
+ {
+ inline static T BOOST_CXX14_CONSTEXPR abs(const T& val) BOOST_GCD_NOEXCEPT(T)
+ {
+ // This sucks, but std::abs is not constexpr :(
+ return val < T(0) ? -val : val;
+ }
+ };
+
+ enum method_type
+ {
+ method_euclid = 0,
+ method_binary = 1,
+ method_mixed = 2
+ };
+
+ struct any_convert
+ {
+ template <class T>
+ any_convert(const T&);
+ };
+
+ struct unlikely_size
+ {
+ char buf[9973];
+ };
+
+ unlikely_size operator <<= (any_convert, any_convert);
+ unlikely_size operator >>= (any_convert, any_convert);
+
+ template <class T>
+ struct gcd_traits_defaults : public gcd_traits_abs_defaults<T>
+ {
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(T& val) BOOST_GCD_NOEXCEPT(T)
+ {
+ unsigned r = 0;
+ while(0 == (val & 1u))
+ {
+#ifdef _MSC_VER // VC++ can't handle operator >>= in constexpr code for some reason
+ val = val >> 1;
+#else
+ val >>= 1;
+#endif
+ ++r;
+ }
+ return r;
+ }
+ inline static BOOST_CXX14_CONSTEXPR bool less(const T& a, const T& b) BOOST_GCD_NOEXCEPT(T)
+ {
+ return a < b;
+ }
+
+ static T& get_value();
+
+#ifndef BOOST_NO_SFINAE
+ static const bool has_operator_left_shift_equal = sizeof(get_value() <<= 2) != sizeof(unlikely_size);
+ static const bool has_operator_right_shift_equal = sizeof(get_value() >>= 2) != sizeof(unlikely_size);
+#else
+ static const bool has_operator_left_shift_equal = true;
+ static const bool has_operator_right_shift_equal = true;
+#endif
+ static const method_type method = std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::is_integer && has_operator_left_shift_equal && has_operator_right_shift_equal ? method_mixed : method_euclid;
+ };
+ //
+ // Default gcd_traits just inherits from defaults:
+ //
+ template <class T>
+ struct gcd_traits : public gcd_traits_defaults<T> {};
+
+ //
+ // Some platforms have fast bitscan operations, that allow us to implement
+ // make_odd much more efficiently, unfortunately we can't use these if we want
+ // the functions to be constexpr as the compiler intrinsics aren't constexpr.
+ //
+#if defined(BOOST_NO_CXX14_CONSTEXPR) && ((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))
+#pragma intrinsic(_BitScanForward,)
+ template <>
+ struct gcd_traits<unsigned long> : public gcd_traits_defaults<unsigned long>
+ {
+ BOOST_FORCEINLINE static unsigned find_lsb(unsigned long val) BOOST_NOEXCEPT
+ {
+ unsigned long result;
+ _BitScanForward(&result, val);
+ return result;
+ }
+ BOOST_FORCEINLINE static unsigned make_odd(unsigned long& val) BOOST_NOEXCEPT
+ {
+ unsigned result = find_lsb(val);
+ val >>= result;
+ return result;
+ }
+ };
+
+#ifdef _M_X64
+#pragma intrinsic(_BitScanForward64)
+ template <>
+ struct gcd_traits<unsigned __int64> : public gcd_traits_defaults<unsigned __int64>
+ {
+ BOOST_FORCEINLINE static unsigned find_lsb(unsigned __int64 mask) BOOST_NOEXCEPT
+ {
+ unsigned long result;
+ _BitScanForward64(&result, mask);
+ return result;
+ }
+ BOOST_FORCEINLINE static unsigned make_odd(unsigned __int64& val) BOOST_NOEXCEPT
+ {
+ unsigned result = find_lsb(val);
+ val >>= result;
+ return result;
+ }
+ };
+#endif
+ //
+ // Other integer type are trivial adaptations of the above,
+ // this works for signed types too, as by the time these functions
+ // are called, all values are > 0.
+ //
+ template <> struct gcd_traits<long> : public gcd_traits_defaults<long>
+ { BOOST_FORCEINLINE static unsigned make_odd(long& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
+ template <> struct gcd_traits<unsigned int> : public gcd_traits_defaults<unsigned int>
+ { BOOST_FORCEINLINE static unsigned make_odd(unsigned int& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
+ template <> struct gcd_traits<int> : public gcd_traits_defaults<int>
+ { BOOST_FORCEINLINE static unsigned make_odd(int& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
+ template <> struct gcd_traits<unsigned short> : public gcd_traits_defaults<unsigned short>
+ { BOOST_FORCEINLINE static unsigned make_odd(unsigned short& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
+ template <> struct gcd_traits<short> : public gcd_traits_defaults<short>
+ { BOOST_FORCEINLINE static unsigned make_odd(short& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
+ template <> struct gcd_traits<unsigned char> : public gcd_traits_defaults<unsigned char>
+ { BOOST_FORCEINLINE static unsigned make_odd(unsigned char& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
+ template <> struct gcd_traits<signed char> : public gcd_traits_defaults<signed char>
+ { BOOST_FORCEINLINE static signed make_odd(signed char& val)BOOST_NOEXCEPT{ signed result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
+ template <> struct gcd_traits<char> : public gcd_traits_defaults<char>
+ { BOOST_FORCEINLINE static unsigned make_odd(char& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
+#ifndef BOOST_NO_INTRINSIC_WCHAR_T
+ template <> struct gcd_traits<wchar_t> : public gcd_traits_defaults<wchar_t>
+ { BOOST_FORCEINLINE static unsigned make_odd(wchar_t& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
+#endif
+#ifdef _M_X64
+ template <> struct gcd_traits<__int64> : public gcd_traits_defaults<__int64>
+ { BOOST_FORCEINLINE static unsigned make_odd(__int64& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned __int64>::find_lsb(val); val >>= result; return result; } };
+#endif
+
+#elif defined(BOOST_GCC) || defined(__clang__) || (defined(BOOST_INTEL) && defined(__GNUC__))
+
+ template <>
+ struct gcd_traits<unsigned> : public gcd_traits_defaults<unsigned>
+ {
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned find_lsb(unsigned mask)BOOST_NOEXCEPT
+ {
+ return __builtin_ctz(mask);
+ }
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(unsigned& val)BOOST_NOEXCEPT
+ {
+ unsigned result = find_lsb(val);
+ val >>= result;
+ return result;
+ }
+ };
+ template <>
+ struct gcd_traits<unsigned long> : public gcd_traits_defaults<unsigned long>
+ {
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned find_lsb(unsigned long mask)BOOST_NOEXCEPT
+ {
+ return __builtin_ctzl(mask);
+ }
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(unsigned long& val)BOOST_NOEXCEPT
+ {
+ unsigned result = find_lsb(val);
+ val >>= result;
+ return result;
+ }
+ };
+ template <>
+ struct gcd_traits<boost::ulong_long_type> : public gcd_traits_defaults<boost::ulong_long_type>
+ {
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned find_lsb(boost::ulong_long_type mask)BOOST_NOEXCEPT
+ {
+ return __builtin_ctzll(mask);
+ }
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(boost::ulong_long_type& val)BOOST_NOEXCEPT
+ {
+ unsigned result = find_lsb(val);
+ val >>= result;
+ return result;
+ }
+ };
+ //
+ // Other integer type are trivial adaptations of the above,
+ // this works for signed types too, as by the time these functions
+ // are called, all values are > 0.
+ //
+ template <> struct gcd_traits<boost::long_long_type> : public gcd_traits_defaults<boost::long_long_type>
+ {
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(boost::long_long_type& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<boost::ulong_long_type>::find_lsb(val); val >>= result; return result; }
+ };
+ template <> struct gcd_traits<long> : public gcd_traits_defaults<long>
+ {
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(long& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; }
+ };
+ template <> struct gcd_traits<int> : public gcd_traits_defaults<int>
+ {
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(int& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; }
+ };
+ template <> struct gcd_traits<unsigned short> : public gcd_traits_defaults<unsigned short>
+ {
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(unsigned short& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
+ };
+ template <> struct gcd_traits<short> : public gcd_traits_defaults<short>
+ {
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(short& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
+ };
+ template <> struct gcd_traits<unsigned char> : public gcd_traits_defaults<unsigned char>
+ {
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(unsigned char& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
+ };
+ template <> struct gcd_traits<signed char> : public gcd_traits_defaults<signed char>
+ {
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR signed make_odd(signed char& val)BOOST_NOEXCEPT { signed result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
+ };
+ template <> struct gcd_traits<char> : public gcd_traits_defaults<char>
+ {
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(char& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
+ };
+#ifndef BOOST_NO_INTRINSIC_WCHAR_T
+ template <> struct gcd_traits<wchar_t> : public gcd_traits_defaults<wchar_t>
+ {
+ BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(wchar_t& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
+ };
+#endif
+#endif
+ //
+ // The Mixed Binary Euclid Algorithm
+ // Sidi Mohamed Sedjelmaci
+ // Electronic Notes in Discrete Mathematics 35 (2009) 169-176
+ //
+ template <class T>
+ BOOST_CXX14_CONSTEXPR T mixed_binary_gcd(T u, T v) BOOST_GCD_NOEXCEPT(T)
+ {
+ if(gcd_traits<T>::less(u, v))
+ constexpr_swap(u, v);
+
+ unsigned shifts = 0;
+
+ if(u == T(0))
+ return v;
+ if(v == T(0))
+ return u;
+
+ shifts = constexpr_min(gcd_traits<T>::make_odd(u), gcd_traits<T>::make_odd(v));
+
+ while(gcd_traits<T>::less(1, v))
+ {
+ u %= v;
+ v -= u;
+ if(u == T(0))
+ return v << shifts;
+ if(v == T(0))
+ return u << shifts;
+ gcd_traits<T>::make_odd(u);
+ gcd_traits<T>::make_odd(v);
+ if(gcd_traits<T>::less(u, v))
+ constexpr_swap(u, v);
+ }
+ return (v == 1 ? v : u) << shifts;
+ }
+
+ /** Stein gcd (aka 'binary gcd')
+ *
+ * From Mathematics to Generic Programming, Alexander Stepanov, Daniel Rose
+ */
+ template <typename SteinDomain>
+ BOOST_CXX14_CONSTEXPR SteinDomain Stein_gcd(SteinDomain m, SteinDomain n) BOOST_GCD_NOEXCEPT(SteinDomain)
+ {
+ BOOST_ASSERT(m >= 0);
+ BOOST_ASSERT(n >= 0);
+ if (m == SteinDomain(0))
+ return n;
+ if (n == SteinDomain(0))
+ return m;
+ // m > 0 && n > 0
+ int d_m = gcd_traits<SteinDomain>::make_odd(m);
+ int d_n = gcd_traits<SteinDomain>::make_odd(n);
+ // odd(m) && odd(n)
+ while (m != n)
+ {
+ if (n > m)
+ constexpr_swap(n, m);
+ m -= n;
+ gcd_traits<SteinDomain>::make_odd(m);
+ }
+ // m == n
+ m <<= constexpr_min(d_m, d_n);
+ return m;
+ }
+
+
+ /** Euclidean algorithm
+ *
+ * From Mathematics to Generic Programming, Alexander Stepanov, Daniel Rose
+ *
+ */
+ template <typename EuclideanDomain>
+ inline BOOST_CXX14_CONSTEXPR EuclideanDomain Euclid_gcd(EuclideanDomain a, EuclideanDomain b) BOOST_GCD_NOEXCEPT(EuclideanDomain)
+ {
+ while (b != EuclideanDomain(0))
+ {
+ a %= b;
+ constexpr_swap(a, b);
+ }
+ return a;
+ }
+
+
+ template <typename T>
+ inline BOOST_CXX14_CONSTEXPR BOOST_DEDUCED_TYPENAME enable_if_c<gcd_traits<T>::method == method_mixed, T>::type
+ optimal_gcd_select(T const &a, T const &b) BOOST_GCD_NOEXCEPT(T)
+ {
+ return gcd_detail::mixed_binary_gcd(a, b);
+ }
+
+ template <typename T>
+ inline BOOST_CXX14_CONSTEXPR BOOST_DEDUCED_TYPENAME enable_if_c<gcd_traits<T>::method == method_binary, T>::type
+ optimal_gcd_select(T const &a, T const &b) BOOST_GCD_NOEXCEPT(T)
+ {
+ return gcd_detail::Stein_gcd(a, b);
+ }
+
+ template <typename T>
+ inline BOOST_CXX14_CONSTEXPR BOOST_DEDUCED_TYPENAME enable_if_c<gcd_traits<T>::method == method_euclid, T>::type
+ optimal_gcd_select(T const &a, T const &b) BOOST_GCD_NOEXCEPT(T)
+ {
+ return gcd_detail::Euclid_gcd(a, b);
+ }
+
+ template <class T>
+ inline BOOST_CXX14_CONSTEXPR T lcm_imp(const T& a, const T& b) BOOST_GCD_NOEXCEPT(T)
+ {
+ T temp = boost::integer::gcd_detail::optimal_gcd_select(a, b);
+#if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40500)
+ return (temp != T(0)) ? T(a / temp * b) : T(0);
+#else
+ return temp != T(0) ? T(a / temp * b) : T(0);
+#endif
+ }
+
+} // namespace detail
+
+
+template <typename Integer>
+inline BOOST_CXX14_CONSTEXPR Integer gcd(Integer const &a, Integer const &b) BOOST_GCD_NOEXCEPT(Integer)
+{
+ if(a == (std::numeric_limits<Integer>::min)())
+ return a == static_cast<Integer>(0) ? gcd_detail::gcd_traits<Integer>::abs(b) : boost::integer::gcd(static_cast<Integer>(a % b), b);
+ else if (b == (std::numeric_limits<Integer>::min)())
+ return b == static_cast<Integer>(0) ? gcd_detail::gcd_traits<Integer>::abs(a) : boost::integer::gcd(a, static_cast<Integer>(b % a));
+ return gcd_detail::optimal_gcd_select(static_cast<Integer>(gcd_detail::gcd_traits<Integer>::abs(a)), static_cast<Integer>(gcd_detail::gcd_traits<Integer>::abs(b)));
+}
+
+template <typename Integer>
+inline BOOST_CXX14_CONSTEXPR Integer lcm(Integer const &a, Integer const &b) BOOST_GCD_NOEXCEPT(Integer)
+{
+ return gcd_detail::lcm_imp(static_cast<Integer>(gcd_detail::gcd_traits<Integer>::abs(a)), static_cast<Integer>(gcd_detail::gcd_traits<Integer>::abs(b)));
+}
+#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
+//
+// This looks slightly odd, but the variadic forms must have 3 or more arguments, and the variadic argument pack may be empty.
+// This matters not at all for most compilers, but Oracle C++ selects the wrong overload in the 2-arg case unless we do this.
+//
+template <typename Integer, typename... Args>
+inline BOOST_CXX14_CONSTEXPR Integer gcd(Integer const &a, Integer const &b, const Integer& c, Args const&... args) BOOST_GCD_NOEXCEPT(Integer)
+{
+ Integer t = gcd(b, c, args...);
+ return t == 1 ? 1 : gcd(a, t);
+}
+
+template <typename Integer, typename... Args>
+inline BOOST_CXX14_CONSTEXPR Integer lcm(Integer const &a, Integer const &b, Integer const& c, Args const&... args) BOOST_GCD_NOEXCEPT(Integer)
+{
+ return lcm(a, lcm(b, c, args...));
+}
+#endif
+//
+// Special handling for rationals:
+//
+template <typename Integer>
+inline typename boost::enable_if_c<std::numeric_limits<Integer>::is_specialized, boost::rational<Integer> >::type gcd(boost::rational<Integer> const &a, boost::rational<Integer> const &b)
+{
+ return boost::rational<Integer>(static_cast<Integer>(gcd(a.numerator(), b.numerator())), static_cast<Integer>(lcm(a.denominator(), b.denominator())));
+}
+
+template <typename Integer>
+inline typename boost::enable_if_c<std::numeric_limits<Integer>::is_specialized, boost::rational<Integer> >::type lcm(boost::rational<Integer> const &a, boost::rational<Integer> const &b)
+{
+ return boost::rational<Integer>(static_cast<Integer>(lcm(a.numerator(), b.numerator())), static_cast<Integer>(gcd(a.denominator(), b.denominator())));
+}
+/**
+ * Knuth, The Art of Computer Programming: Volume 2, Third edition, 1998
+ * Chapter 4.5.2, Algorithm C: Greatest common divisor of n integers.
+ *
+ * Knuth counts down from n to zero but we naturally go from first to last.
+ * We also return the termination position because it might be useful to know.
+ *
+ * Partly by quirk, partly by design, this algorithm is defined for n = 1,
+ * because the gcd of {x} is x. It is not defined for n = 0.
+ *
+ * @tparam I Input iterator.
+ * @return The gcd of the range and the iterator position at termination.
+ */
+template <typename I>
+std::pair<typename std::iterator_traits<I>::value_type, I>
+gcd_range(I first, I last) BOOST_GCD_NOEXCEPT(I)
+{
+ BOOST_ASSERT(first != last);
+ typedef typename std::iterator_traits<I>::value_type T;
+
+ T d = *first++;
+ while (d != T(1) && first != last)
+ {
+ d = gcd(d, *first);
+ first++;
+ }
+ return std::make_pair(d, first);
+}
+template <typename I>
+std::pair<typename std::iterator_traits<I>::value_type, I>
+lcm_range(I first, I last) BOOST_GCD_NOEXCEPT(I)
+{
+ BOOST_ASSERT(first != last);
+ typedef typename std::iterator_traits<I>::value_type T;
+
+ T d = *first++;
+ while (d != T(1) && first != last)
+ {
+ d = lcm(d, *first);
+ first++;
+ }
+ return std::make_pair(d, first);
+}
+
+template < typename IntegerType >
+class gcd_evaluator
+#ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
+ : public std::binary_function<IntegerType, IntegerType, IntegerType>
+#endif
+{
+public:
+#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
+ typedef IntegerType first_argument_type;
+ typedef IntegerType second_argument_type;
+ typedef IntegerType result_type;
+#endif
+ IntegerType operator()(IntegerType const &a, IntegerType const &b)const
+ {
+ return boost::integer::gcd(a, b);
+ }
+};
+
+template < typename IntegerType >
+class lcm_evaluator
+#ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
+ : public std::binary_function<IntegerType, IntegerType, IntegerType>
+#endif
+{
+public:
+#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
+ typedef IntegerType first_argument_type;
+ typedef IntegerType second_argument_type;
+ typedef IntegerType result_type;
+#endif
+ IntegerType operator()(IntegerType const &a, IntegerType const &b)const
+ {
+ return boost::integer::lcm(a, b);
+ }
+};
+
+} // namespace integer
+} // namespace boost
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
+#endif // BOOST_INTEGER_COMMON_FACTOR_RT_HPP
diff --git a/include/boost/integer/integer_log2.hpp b/include/boost/integer/integer_log2.hpp
new file mode 100644
index 0000000..8b34ce7
--- /dev/null
+++ b/include/boost/integer/integer_log2.hpp
@@ -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
diff --git a/include/boost/integer/integer_mask.hpp b/include/boost/integer/integer_mask.hpp
new file mode 100644
index 0000000..eee4679
--- /dev/null
+++ b/include/boost/integer/integer_mask.hpp
@@ -0,0 +1,134 @@
+// Boost integer/integer_mask.hpp header file ------------------------------//
+
+// (C) Copyright Daryle Walker 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 for updates, documentation, and revision history.
+
+#ifndef BOOST_INTEGER_INTEGER_MASK_HPP
+#define BOOST_INTEGER_INTEGER_MASK_HPP
+
+#include <boost/integer_fwd.hpp> // self include
+
+#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
+#include <boost/integer.hpp> // for boost::uint_t
+
+#include <climits> // for UCHAR_MAX, etc.
+#include <cstddef> // for std::size_t
+
+#include <boost/limits.hpp> // for std::numeric_limits
+
+//
+// We simply cannot include this header on gcc without getting copious warnings of the kind:
+//
+// boost/integer/integer_mask.hpp:93:35: warning: use of C99 long long integer constant
+//
+// And yet there is no other reasonable implementation, so we declare this a system header
+// to suppress these warnings.
+//
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#pragma GCC system_header
+#endif
+
+namespace boost
+{
+
+
+// Specified single-bit mask class declaration -----------------------------//
+// (Lowest bit starts counting at 0.)
+
+template < std::size_t Bit >
+struct high_bit_mask_t
+{
+ typedef typename uint_t<(Bit + 1)>::least least;
+ typedef typename uint_t<(Bit + 1)>::fast fast;
+
+ BOOST_STATIC_CONSTANT( least, high_bit = (least( 1u ) << Bit) );
+ BOOST_STATIC_CONSTANT( fast, high_bit_fast = (fast( 1u ) << Bit) );
+
+ BOOST_STATIC_CONSTANT( std::size_t, bit_position = Bit );
+
+}; // boost::high_bit_mask_t
+
+
+// Specified bit-block mask class declaration ------------------------------//
+// Makes masks for the lowest N bits
+// (Specializations are needed when N fills up a type.)
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4310) // cast truncates constant value
+#endif
+
+template < std::size_t Bits >
+struct low_bits_mask_t
+{
+ typedef typename uint_t<Bits>::least least;
+ typedef typename uint_t<Bits>::fast fast;
+
+ BOOST_STATIC_CONSTANT( least, sig_bits = least(~(least(~(least( 0u ))) << Bits )) );
+ BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) );
+
+ BOOST_STATIC_CONSTANT( std::size_t, bit_count = Bits );
+
+}; // boost::low_bits_mask_t
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
+#define BOOST_LOW_BITS_MASK_SPECIALIZE( Type ) \
+ template < > struct low_bits_mask_t< std::numeric_limits<Type>::digits > { \
+ typedef std::numeric_limits<Type> limits_type; \
+ typedef uint_t<limits_type::digits>::least least; \
+ typedef uint_t<limits_type::digits>::fast fast; \
+ BOOST_STATIC_CONSTANT( least, sig_bits = (~( least(0u) )) ); \
+ BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) ); \
+ BOOST_STATIC_CONSTANT( std::size_t, bit_count = limits_type::digits ); \
+ }
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4245) // 'initializing' : conversion from 'int' to 'const boost::low_bits_mask_t<8>::least', signed/unsigned mismatch
+#endif
+
+BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned char );
+
+#if USHRT_MAX > UCHAR_MAX
+BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned short );
+#endif
+
+#if UINT_MAX > USHRT_MAX
+BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned int );
+#endif
+
+#if ULONG_MAX > UINT_MAX
+BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned long );
+#endif
+
+#if defined(BOOST_HAS_LONG_LONG)
+ #if ((defined(ULLONG_MAX) && (ULLONG_MAX > ULONG_MAX)) ||\
+ (defined(ULONG_LONG_MAX) && (ULONG_LONG_MAX > ULONG_MAX)) ||\
+ (defined(ULONGLONG_MAX) && (ULONGLONG_MAX > ULONG_MAX)) ||\
+ (defined(_ULLONG_MAX) && (_ULLONG_MAX > ULONG_MAX)))
+ BOOST_LOW_BITS_MASK_SPECIALIZE( boost::ulong_long_type );
+ #endif
+#elif defined(BOOST_HAS_MS_INT64)
+ #if 18446744073709551615ui64 > ULONG_MAX
+ BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned __int64 );
+ #endif
+#endif
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
+#undef BOOST_LOW_BITS_MASK_SPECIALIZE
+
+
+} // namespace boost
+
+
+#endif // BOOST_INTEGER_INTEGER_MASK_HPP
diff --git a/include/boost/integer/static_log2.hpp b/include/boost/integer/static_log2.hpp
new file mode 100644
index 0000000..56c7a00
--- /dev/null
+++ b/include/boost/integer/static_log2.hpp
@@ -0,0 +1,127 @@
+// -------------- Boost static_log2.hpp header file ----------------------- //
+//
+// Copyright (C) 2001 Daryle Walker.
+// Copyright (C) 2003 Vesa Karvonen.
+// Copyright (C) 2003 Gennaro Prota.
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// ---------------------------------------------------
+// See http://www.boost.org/libs/integer for documentation.
+// ------------------------------------------------------------------------- //
+
+
+#ifndef BOOST_INTEGER_STATIC_LOG2_HPP
+#define BOOST_INTEGER_STATIC_LOG2_HPP
+
+#include "boost/integer_fwd.hpp" // for boost::intmax_t
+
+namespace boost {
+
+ namespace detail {
+
+ namespace static_log2_impl {
+
+ // choose_initial_n<>
+ //
+ // Recursively doubles its integer argument, until it
+ // becomes >= of the "width" (C99, 6.2.6.2p4) of
+ // static_log2_argument_type.
+ //
+ // Used to get the maximum power of two less then the width.
+ //
+ // Example: if on your platform argument_type has 48 value
+ // bits it yields n=32.
+ //
+ // It's easy to prove that, starting from such a value
+ // of n, the core algorithm works correctly for any width
+ // of static_log2_argument_type and that recursion always
+ // terminates with x = 1 and n = 0 (see the algorithm's
+ // invariant).
+
+ typedef boost::static_log2_argument_type argument_type;
+ typedef boost::static_log2_result_type result_type;
+
+ template <result_type n>
+ struct choose_initial_n {
+
+ BOOST_STATIC_CONSTANT(bool, c = (argument_type(1) << n << n) != 0);
+ BOOST_STATIC_CONSTANT(
+ result_type,
+ value = !c*n + choose_initial_n<2*c*n>::value
+ );
+
+ };
+
+ template <>
+ struct choose_initial_n<0> {
+ BOOST_STATIC_CONSTANT(result_type, value = 0);
+ };
+
+
+
+ // start computing from n_zero - must be a power of two
+ const result_type n_zero = 16;
+ const result_type initial_n = choose_initial_n<n_zero>::value;
+
+ // static_log2_impl<>
+ //
+ // * Invariant:
+ // 2n
+ // 1 <= x && x < 2 at the start of each recursion
+ // (see also choose_initial_n<>)
+ //
+ // * Type requirements:
+ //
+ // argument_type maybe any unsigned type with at least n_zero + 1
+ // value bits. (Note: If larger types will be standardized -e.g.
+ // unsigned long long- then the argument_type typedef can be
+ // changed without affecting the rest of the code.)
+ //
+
+ template <argument_type x, result_type n = initial_n>
+ struct static_log2_impl {
+
+ BOOST_STATIC_CONSTANT(bool, c = (x >> n) > 0); // x >= 2**n ?
+ BOOST_STATIC_CONSTANT(
+ result_type,
+ value = c*n + (static_log2_impl< (x>>c*n), n/2 >::value)
+ );
+
+ };
+
+ template <>
+ struct static_log2_impl<1, 0> {
+ BOOST_STATIC_CONSTANT(result_type, value = 0);
+ };
+
+ }
+ } // detail
+
+
+
+ // --------------------------------------
+ // static_log2<x>
+ // ----------------------------------------
+
+ template <static_log2_argument_type x>
+ struct static_log2 {
+
+ BOOST_STATIC_CONSTANT(
+ static_log2_result_type,
+ value = detail::static_log2_impl::static_log2_impl<x>::value
+ );
+
+ };
+
+
+ template <>
+ struct static_log2<0> { };
+
+}
+
+
+
+#endif // include guard
diff --git a/include/boost/integer/static_min_max.hpp b/include/boost/integer/static_min_max.hpp
new file mode 100644
index 0000000..ee76fd4
--- /dev/null
+++ b/include/boost/integer/static_min_max.hpp
@@ -0,0 +1,51 @@
+// Boost integer/static_min_max.hpp header file ----------------------------//
+
+// (C) Copyright Daryle Walker 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 for updates, documentation, and revision history.
+
+#ifndef BOOST_INTEGER_STATIC_MIN_MAX_HPP
+#define BOOST_INTEGER_STATIC_MIN_MAX_HPP
+
+#include <boost/integer_fwd.hpp> // self include
+
+namespace boost
+{
+
+// Compile-time extrema class declarations ---------------------------------//
+// Get the minimum or maximum of two values, signed or unsigned.
+
+template <static_min_max_signed_type Value1, static_min_max_signed_type Value2>
+struct static_signed_min
+{
+ BOOST_STATIC_CONSTANT(static_min_max_signed_type, value = (Value1 > Value2) ? Value2 : Value1 );
+};
+
+template <static_min_max_signed_type Value1, static_min_max_signed_type Value2>
+struct static_signed_max
+{
+ BOOST_STATIC_CONSTANT(static_min_max_signed_type, value = (Value1 < Value2) ? Value2 : Value1 );
+};
+
+template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
+struct static_unsigned_min
+{
+ BOOST_STATIC_CONSTANT(static_min_max_unsigned_type, value
+ = (Value1 > Value2) ? Value2 : Value1 );
+};
+
+template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
+struct static_unsigned_max
+{
+ BOOST_STATIC_CONSTANT(static_min_max_unsigned_type, value
+ = (Value1 < Value2) ? Value2 : Value1 );
+};
+
+
+} // namespace boost
+
+
+#endif // BOOST_INTEGER_STATIC_MIN_MAX_HPP
diff --git a/include/boost/integer_fwd.hpp b/include/boost/integer_fwd.hpp
new file mode 100644
index 0000000..18519dd
--- /dev/null
+++ b/include/boost/integer_fwd.hpp
@@ -0,0 +1,190 @@
+// Boost integer_fwd.hpp header file ---------------------------------------//
+
+// (C) Copyright Dave Abrahams and Daryle Walker 2001. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/integer for documentation.
+
+#ifndef BOOST_INTEGER_FWD_HPP
+#define BOOST_INTEGER_FWD_HPP
+
+#include <climits> // for UCHAR_MAX, etc.
+#include <cstddef> // for std::size_t
+
+#include <boost/config.hpp> // for BOOST_NO_INTRINSIC_WCHAR_T
+#include <boost/limits.hpp> // for std::numeric_limits
+#include <boost/cstdint.hpp> // For intmax_t
+
+
+namespace boost
+{
+
+#ifdef BOOST_NO_INTEGRAL_INT64_T
+ typedef unsigned long static_log2_argument_type;
+ typedef int static_log2_result_type;
+ typedef long static_min_max_signed_type;
+ typedef unsigned long static_min_max_unsigned_type;
+#else
+ typedef boost::uintmax_t static_min_max_unsigned_type;
+ typedef boost::intmax_t static_min_max_signed_type;
+ typedef boost::uintmax_t static_log2_argument_type;
+ typedef int static_log2_result_type;
+#endif
+
+// From <boost/cstdint.hpp> ------------------------------------------------//
+
+// Only has typedefs or using statements, with #conditionals
+
+
+// From <boost/integer_traits.hpp> -----------------------------------------//
+
+template < class T >
+ class integer_traits;
+
+template < >
+ class integer_traits< bool >;
+
+template < >
+ class integer_traits< char >;
+
+template < >
+ class integer_traits< signed char >;
+
+template < >
+ class integer_traits< unsigned char >;
+
+#ifndef BOOST_NO_INTRINSIC_WCHAR_T
+template < >
+ class integer_traits< wchar_t >;
+#endif
+
+template < >
+ class integer_traits< short >;
+
+template < >
+ class integer_traits< unsigned short >;
+
+template < >
+ class integer_traits< int >;
+
+template < >
+ class integer_traits< unsigned int >;
+
+template < >
+ class integer_traits< long >;
+
+template < >
+ class integer_traits< unsigned long >;
+
+#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
+template < >
+class integer_traits< ::boost::long_long_type>;
+
+template < >
+class integer_traits< ::boost::ulong_long_type >;
+#elif !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_MS_INT64)
+template < >
+class integer_traits<__int64>;
+
+template < >
+class integer_traits<unsigned __int64>;
+#endif
+
+
+// From <boost/integer.hpp> ------------------------------------------------//
+
+template < typename LeastInt >
+ struct int_fast_t;
+
+template< int Bits >
+ struct int_t;
+
+template< int Bits >
+ struct uint_t;
+
+#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
+ template< boost::long_long_type MaxValue > // maximum value to require support
+#else
+ template< long MaxValue > // maximum value to require support
+#endif
+ struct int_max_value_t;
+
+#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
+ template< boost::long_long_type MinValue > // minimum value to require support
+#else
+ template< long MinValue > // minimum value to require support
+#endif
+ struct int_min_value_t;
+
+#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
+ template< boost::ulong_long_type MaxValue > // maximum value to require support
+#else
+ template< unsigned long MaxValue > // maximum value to require support
+#endif
+ struct uint_value_t;
+
+
+// From <boost/integer/integer_mask.hpp> -----------------------------------//
+
+template < std::size_t Bit >
+ struct high_bit_mask_t;
+
+template < std::size_t Bits >
+ struct low_bits_mask_t;
+
+template < >
+ struct low_bits_mask_t< ::std::numeric_limits<unsigned char>::digits >;
+
+// From <boost/integer/static_log2.hpp> ------------------------------------//
+
+template <static_log2_argument_type Value >
+ struct static_log2;
+
+template <> struct static_log2<0u>;
+
+
+// From <boost/integer/static_min_max.hpp> ---------------------------------//
+
+template <static_min_max_signed_type Value1, static_min_max_signed_type Value2>
+ struct static_signed_min;
+
+template <static_min_max_signed_type Value1, static_min_max_signed_type Value2>
+ struct static_signed_max;
+
+template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
+ struct static_unsigned_min;
+
+template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
+ struct static_unsigned_max;
+
+
+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
+
+
+#endif // BOOST_INTEGER_FWD_HPP
diff --git a/include/boost/integer_traits.hpp b/include/boost/integer_traits.hpp
new file mode 100644
index 0000000..94eb00d
--- /dev/null
+++ b/include/boost/integer_traits.hpp
@@ -0,0 +1,256 @@
+/* boost integer_traits.hpp header file
+ *
+ * Copyright Jens Maurer 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)
+ *
+ * $Id$
+ *
+ * Idea by Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers
+ */
+
+// See http://www.boost.org/libs/integer for documentation.
+
+
+#ifndef BOOST_INTEGER_TRAITS_HPP
+#define BOOST_INTEGER_TRAITS_HPP
+
+#include <boost/config.hpp>
+#include <boost/limits.hpp>
+
+// These are an implementation detail and not part of the interface
+#include <limits.h>
+// we need wchar.h for WCHAR_MAX/MIN but not all platforms provide it,
+// and some may have <wchar.h> but not <cwchar> ...
+#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) && (!defined(BOOST_NO_CWCHAR) || defined(sun) || defined(__sun) || defined(__QNX__))
+#include <wchar.h>
+#endif
+
+//
+// We simply cannot include this header on gcc without getting copious warnings of the kind:
+//
+// ../../../boost/integer_traits.hpp:164:66: warning: use of C99 long long integer constant
+//
+// And yet there is no other reasonable implementation, so we declare this a system header
+// to suppress these warnings.
+//
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#pragma GCC system_header
+#endif
+
+namespace boost {
+template<class T>
+class integer_traits : public std::numeric_limits<T>
+{
+public:
+ BOOST_STATIC_CONSTANT(bool, is_integral = false);
+};
+
+namespace detail {
+template<class T, T min_val, T max_val>
+class integer_traits_base
+{
+public:
+ BOOST_STATIC_CONSTANT(bool, is_integral = true);
+ BOOST_STATIC_CONSTANT(T, const_min = min_val);
+ BOOST_STATIC_CONSTANT(T, const_max = max_val);
+};
+
+#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
+// A definition is required even for integral static constants
+template<class T, T min_val, T max_val>
+const bool integer_traits_base<T, min_val, max_val>::is_integral;
+
+template<class T, T min_val, T max_val>
+const T integer_traits_base<T, min_val, max_val>::const_min;
+
+template<class T, T min_val, T max_val>
+const T integer_traits_base<T, min_val, max_val>::const_max;
+#endif
+
+} // namespace detail
+
+template<>
+class integer_traits<bool>
+ : public std::numeric_limits<bool>,
+ public detail::integer_traits_base<bool, false, true>
+{ };
+
+template<>
+class integer_traits<char>
+ : public std::numeric_limits<char>,
+ public detail::integer_traits_base<char, CHAR_MIN, CHAR_MAX>
+{ };
+
+template<>
+class integer_traits<signed char>
+ : public std::numeric_limits<signed char>,
+ public detail::integer_traits_base<signed char, SCHAR_MIN, SCHAR_MAX>
+{ };
+
+template<>
+class integer_traits<unsigned char>
+ : public std::numeric_limits<unsigned char>,
+ public detail::integer_traits_base<unsigned char, 0, UCHAR_MAX>
+{ };
+
+#ifndef BOOST_NO_INTRINSIC_WCHAR_T
+template<>
+class integer_traits<wchar_t>
+ : public std::numeric_limits<wchar_t>,
+ // Don't trust WCHAR_MIN and WCHAR_MAX with Mac OS X's native
+ // library: they are wrong!
+#if defined(WCHAR_MIN) && defined(WCHAR_MAX) && !defined(__APPLE__)
+ public detail::integer_traits_base<wchar_t, WCHAR_MIN, WCHAR_MAX>
+#elif defined(__BORLANDC__) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__BEOS__) && defined(__GNUC__))
+ // No WCHAR_MIN and WCHAR_MAX, whar_t is short and unsigned:
+ public detail::integer_traits_base<wchar_t, 0, 0xffff>
+#elif (defined(__sgi) && (!defined(__SGI_STL_PORT) || __SGI_STL_PORT < 0x400))\
+ || (defined __APPLE__)\
+ || (defined(__OpenBSD__) && defined(__GNUC__))\
+ || (defined(__NetBSD__) && defined(__GNUC__))\
+ || (defined(__FreeBSD__) && defined(__GNUC__))\
+ || (defined(__DragonFly__) && defined(__GNUC__))\
+ || (defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 3) && !defined(__SGI_STL_PORT))
+ // No WCHAR_MIN and WCHAR_MAX, wchar_t has the same range as int.
+ // - SGI MIPSpro with native library
+ // - gcc 3.x on HP-UX
+ // - Mac OS X with native library
+ // - gcc on FreeBSD, OpenBSD and NetBSD
+ public detail::integer_traits_base<wchar_t, INT_MIN, INT_MAX>
+#else
+#error No WCHAR_MIN and WCHAR_MAX present, please adjust integer_traits<> for your compiler.
+#endif
+{ };
+#endif // BOOST_NO_INTRINSIC_WCHAR_T
+
+template<>
+class integer_traits<short>
+ : public std::numeric_limits<short>,
+ public detail::integer_traits_base<short, SHRT_MIN, SHRT_MAX>
+{ };
+
+template<>
+class integer_traits<unsigned short>
+ : public std::numeric_limits<unsigned short>,
+ public detail::integer_traits_base<unsigned short, 0, USHRT_MAX>
+{ };
+
+template<>
+class integer_traits<int>
+ : public std::numeric_limits<int>,
+ public detail::integer_traits_base<int, INT_MIN, INT_MAX>
+{ };
+
+template<>
+class integer_traits<unsigned int>
+ : public std::numeric_limits<unsigned int>,
+ public detail::integer_traits_base<unsigned int, 0, UINT_MAX>
+{ };
+
+template<>
+class integer_traits<long>
+ : public std::numeric_limits<long>,
+ public detail::integer_traits_base<long, LONG_MIN, LONG_MAX>
+{ };
+
+template<>
+class integer_traits<unsigned long>
+ : public std::numeric_limits<unsigned long>,
+ public detail::integer_traits_base<unsigned long, 0, ULONG_MAX>
+{ };
+
+#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T)
+#if defined(ULLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
+
+template<>
+class integer_traits< ::boost::long_long_type>
+ : public std::numeric_limits< ::boost::long_long_type>,
+ public detail::integer_traits_base< ::boost::long_long_type, LLONG_MIN, LLONG_MAX>
+{ };
+
+template<>
+class integer_traits< ::boost::ulong_long_type>
+ : public std::numeric_limits< ::boost::ulong_long_type>,
+ public detail::integer_traits_base< ::boost::ulong_long_type, 0, ULLONG_MAX>
+{ };
+
+#elif defined(ULONG_LONG_MAX) && defined(BOOST_HAS_LONG_LONG)
+
+template<>
+class integer_traits< ::boost::long_long_type> : public std::numeric_limits< ::boost::long_long_type>, public detail::integer_traits_base< ::boost::long_long_type, LONG_LONG_MIN, LONG_LONG_MAX>{ };
+template<>
+class integer_traits< ::boost::ulong_long_type>
+ : public std::numeric_limits< ::boost::ulong_long_type>,
+ public detail::integer_traits_base< ::boost::ulong_long_type, 0, ULONG_LONG_MAX>
+{ };
+
+#elif defined(ULONGLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
+
+template<>
+class integer_traits< ::boost::long_long_type>
+ : public std::numeric_limits< ::boost::long_long_type>,
+ public detail::integer_traits_base< ::boost::long_long_type, LONGLONG_MIN, LONGLONG_MAX>
+{ };
+
+template<>
+class integer_traits< ::boost::ulong_long_type>
+ : public std::numeric_limits< ::boost::ulong_long_type>,
+ public detail::integer_traits_base< ::boost::ulong_long_type, 0, ULONGLONG_MAX>
+{ };
+
+#elif defined(_LLONG_MAX) && defined(_C2) && defined(BOOST_HAS_LONG_LONG)
+
+template<>
+class integer_traits< ::boost::long_long_type>
+ : public std::numeric_limits< ::boost::long_long_type>,
+ public detail::integer_traits_base< ::boost::long_long_type, -_LLONG_MAX - _C2, _LLONG_MAX>
+{ };
+
+template<>
+class integer_traits< ::boost::ulong_long_type>
+ : public std::numeric_limits< ::boost::ulong_long_type>,
+ public detail::integer_traits_base< ::boost::ulong_long_type, 0, _ULLONG_MAX>
+{ };
+
+#elif defined(BOOST_HAS_LONG_LONG)
+//
+// we have long long but no constants, this happens for example with gcc in -ansi mode,
+// we'll just have to work out the values for ourselves (assumes 2's compliment representation):
+//
+template<>
+class integer_traits< ::boost::long_long_type>
+ : public std::numeric_limits< ::boost::long_long_type>,
+ public detail::integer_traits_base< ::boost::long_long_type, (1LL << (sizeof(::boost::long_long_type) * CHAR_BIT - 1)), ~(1LL << (sizeof(::boost::long_long_type) * CHAR_BIT - 1))>
+{ };
+
+template<>
+class integer_traits< ::boost::ulong_long_type>
+ : public std::numeric_limits< ::boost::ulong_long_type>,
+ public detail::integer_traits_base< ::boost::ulong_long_type, 0, ~0uLL>
+{ };
+
+#elif defined(BOOST_HAS_MS_INT64)
+
+template<>
+class integer_traits< __int64>
+ : public std::numeric_limits< __int64>,
+ public detail::integer_traits_base< __int64, _I64_MIN, _I64_MAX>
+{ };
+
+template<>
+class integer_traits< unsigned __int64>
+ : public std::numeric_limits< unsigned __int64>,
+ public detail::integer_traits_base< unsigned __int64, 0, _UI64_MAX>
+{ };
+
+#endif
+#endif
+
+} // namespace boost
+
+#endif /* BOOST_INTEGER_TRAITS_HPP */
+
+
+
diff --git a/include/boost/pending/integer_log2.hpp b/include/boost/pending/integer_log2.hpp
new file mode 100644
index 0000000..023ec7a
--- /dev/null
+++ b/include/boost/pending/integer_log2.hpp
@@ -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
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..dfc23cc
--- /dev/null
+++ b/index.html
@@ -0,0 +1,16 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0; URL=doc/html/index.html">
+</head>
+<body>
+Automatic redirection failed, please go to
+<a href="doc/html/index.html">doc/html/index.html</a>.
+ <P>Copyright Beman Dawes, Daryle Walker, Gennaro Prota and John Maddock 2001-2009</P>
+ <P>Distributed under the Boost Software License, Version 1.0. (See accompanying file <A href="../../LICENSE_1_0.txt">
+ LICENSE_1_0.txt</A> or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</A>).</P>
+</body>
+</html>
+
+
+
+
diff --git a/meta/libraries.json b/meta/libraries.json
new file mode 100644
index 0000000..6345c37
--- /dev/null
+++ b/meta/libraries.json
@@ -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>"
+ ]
+}
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
new file mode 100644
index 0000000..31dcd2a
--- /dev/null
+++ b/test/Jamfile.v2
@@ -0,0 +1,35 @@
+#~ Copyright Rene Rivera 2008
+#~ 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)
+
+import testing ;
+
+project : requirements <warnings>all <toolset>gcc:<cxxflags>-Wextra ;
+
+obj has_gmpxx : has_gmpxx.cpp ;
+explicit has_gmpxx ;
+
+test-suite integer
+ :
+ [ run integer_traits_test.cpp ]
+ [ run integer_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-long-long <toolset>darwin:<cxxflags>-Wno-long-long <toolset>sun:<cxxflags>"-Qoption ccfe -tmpldepth=128" ]
+ [ run integer_mask_test.cpp ]
+ [ run static_log2_test.cpp ]
+ [ run static_min_max_test.cpp ]
+ [ compile integer_traits_include_test.cpp ]
+ [ compile integer_include_test.cpp ]
+ [ compile integer_mask_include_test.cpp ]
+ [ compile static_log2_include_test.cpp ]
+ [ compile static_min_max_include_test.cpp ]
+ [ compile integer_fwd_include_test.cpp ]
+ [ compile gcd_constexpr14_test.cpp ]
+ [ compile gcd_noexcept_test.cpp ]
+ [ compile-fail fail_int_exact.cpp ]
+ [ compile-fail fail_int_fast.cpp ]
+ [ compile-fail fail_int_least.cpp ]
+ [ compile-fail fail_uint_exact.cpp ]
+ [ compile-fail fail_uint_fast.cpp ]
+ [ compile-fail fail_uint_least.cpp ]
+ [ compile-fail fail_uint_65.cpp ]
+ [ run common_factor_test.cpp : : : [ check-target-builds has_gmpxx "Checking for gmpxx.h" : <define>BOOST_INTEGER_HAS_GMPXX_H=1 <linkflags>-lgmp <linkflags>-lgmpxx ] ]
+ ;
diff --git a/test/common_factor_test.cpp b/test/common_factor_test.cpp
new file mode 100644
index 0000000..fa12338
--- /dev/null
+++ b/test/common_factor_test.cpp
@@ -0,0 +1,645 @@
+// 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.integer GCD & LCM unit tests"
+
+#include <boost/config.hpp> // for BOOST_MSVC, etc.
+#include <boost/detail/workaround.hpp>
+#include <boost/integer/common_factor.hpp> // for boost::integer::gcd, etc.
+#include <boost/mpl/list.hpp> // for boost::mpl::list
+#include <boost/operators.hpp>
+#include <boost/core/lightweight_test.hpp>
+#include <boost/random.hpp>
+#include <boost/rational.hpp>
+
+#include <istream> // for std::basic_istream
+#include <limits> // for std::numeric_limits
+#include <ostream> // for std::basic_ostream
+
+#ifdef BOOST_INTEGER_HAS_GMPXX_H
+#include <gmpxx.h>
+#endif
+
+#if (defined(BOOST_MSVC) && (BOOST_MSVC < 1500)) || (defined(__clang_major__) && (__clang_major__ == 3) && (__clang_minor__ < 2))
+#define DISABLE_MP_TESTS
+#endif
+
+#ifndef DISABLE_MP_TESTS
+#include <boost/multiprecision/cpp_int.hpp>
+#endif
+
+namespace {
+
+// TODO: add polynominal/non-real type; especially after any switch to the
+// binary-GCD algorithm for built-in types
+
+// Custom integer class (template)
+template < typename IntType, int ID = 0 >
+class my_wrapped_integer
+ : private ::boost::shiftable1<my_wrapped_integer<IntType, ID>,
+ ::boost::operators<my_wrapped_integer<IntType, ID> > >
+{
+ // Helper type-aliases
+ typedef my_wrapped_integer self_type;
+ typedef IntType self_type::* bool_type;
+
+ // Member data
+ IntType v_;
+
+public:
+ // Template parameters
+ typedef IntType int_type;
+
+ BOOST_STATIC_CONSTANT(int,id = ID);
+
+ // Lifetime management (use automatic destructor and copy constructor)
+ my_wrapped_integer( int_type const &v = int_type() ) : v_( v ) {}
+
+ // Accessors
+ int_type value() const { return this->v_; }
+
+ // Operators (use automatic copy assignment)
+ operator bool_type() const { return this->v_ ? &self_type::v_ : 0; }
+
+ self_type & operator ++() { ++this->v_; return *this; }
+ self_type & operator --() { --this->v_; return *this; }
+
+ self_type operator ~() const { return self_type( ~this->v_ ); }
+ self_type operator !() const { return self_type( !this->v_ ); }
+ self_type operator +() const { return self_type( +this->v_ ); }
+ self_type operator -() const { return self_type( -this->v_ ); }
+
+ bool operator <( self_type const &r ) const { return this->v_ < r.v_; }
+ bool operator ==( self_type const &r ) const { return this->v_ == r.v_; }
+
+ self_type &operator *=(self_type const &r) {this->v_ *= r.v_; return *this;}
+ self_type &operator /=(self_type const &r) {this->v_ /= r.v_; return *this;}
+ self_type &operator %=(self_type const &r) {this->v_ %= r.v_; return *this;}
+ self_type &operator +=(self_type const &r) {this->v_ += r.v_; return *this;}
+ self_type &operator -=(self_type const &r) {this->v_ -= r.v_; return *this;}
+ self_type &operator<<=(self_type const &r){this->v_ <<= r.v_; return *this;}
+ self_type &operator>>=(self_type const &r){this->v_ >>= r.v_; return *this;}
+ self_type &operator &=(self_type const &r) {this->v_ &= r.v_; return *this;}
+ self_type &operator |=(self_type const &r) {this->v_ |= r.v_; return *this;}
+ self_type &operator ^=(self_type const &r) {this->v_ ^= r.v_; return *this;}
+
+ // Input & output
+ friend std::istream & operator >>( std::istream &i, self_type &x )
+ { return i >> x.v_; }
+
+ friend std::ostream & operator <<( std::ostream &o, self_type const &x )
+ { return o << x.v_; }
+
+}; // my_wrapped_integer
+
+template < typename IntType, int ID >
+my_wrapped_integer<IntType, ID> abs( my_wrapped_integer<IntType, ID> const &x )
+{ return ( x < my_wrapped_integer<IntType, ID>(0) ) ? -x : +x; }
+
+typedef my_wrapped_integer<int> MyInt1;
+typedef my_wrapped_integer<unsigned> MyUnsigned1;
+typedef my_wrapped_integer<int, 1> MyInt2;
+typedef my_wrapped_integer<unsigned, 1> MyUnsigned2;
+
+// Without these explicit instantiations, MSVC++ 6.5/7.0 does not find
+// some friend operators in certain contexts.
+MyInt1 dummy1;
+MyUnsigned1 dummy2;
+MyInt2 dummy3;
+MyUnsigned2 dummy4;
+
+// Various types to test with each GCD/LCM
+typedef ::boost::mpl::list<signed char, short, int, long,
+#if BOOST_WORKAROUND(BOOST_MSVC, <= 1500)
+#elif defined(BOOST_HAS_LONG_LONG)
+ boost::long_long_type,
+#elif defined(BOOST_HAS_MS_INT64)
+ __int64,
+#endif
+ MyInt1
+#ifndef DISABLE_MP_TESTS
+ , boost::multiprecision::cpp_int
+#endif
+> signed_test_types;
+typedef ::boost::mpl::list<unsigned char, unsigned short, unsigned,
+ unsigned long,
+#if BOOST_WORKAROUND(BOOST_MSVC, <= 1500)
+#elif defined(BOOST_HAS_LONG_LONG)
+ boost::ulong_long_type,
+#elif defined(BOOST_HAS_MS_INT64)
+ unsigned __int64,
+#endif
+ MyUnsigned1, MyUnsigned2 /*, boost::multiprecision::uint256_t*/> unsigned_test_types;
+
+} // namespace
+
+#define BOOST_NO_MACRO_EXPAND /**/
+
+// Specialize numeric_limits for _some_ of our types
+namespace std
+{
+
+template < >
+class numeric_limits< MyInt1 >
+{
+ typedef MyInt1::int_type int_type;
+ typedef numeric_limits<int_type> limits_type;
+
+public:
+ BOOST_STATIC_CONSTANT(bool, is_specialized = limits_type::is_specialized);
+
+ static MyInt1 min BOOST_NO_MACRO_EXPAND() throw() { return (limits_type::min)(); }
+ static MyInt1 max BOOST_NO_MACRO_EXPAND() throw() { return (limits_type::max)(); }
+
+ BOOST_STATIC_CONSTANT(int, digits = limits_type::digits);
+ BOOST_STATIC_CONSTANT(int, digits10 = limits_type::digits10);
+#ifndef BOOST_NO_CXX11_NUMERIC_LIMITS
+ BOOST_STATIC_CONSTANT(int, max_digits10 = limits_type::max_digits10);
+#endif
+ BOOST_STATIC_CONSTANT(bool, is_signed = limits_type::is_signed);
+ BOOST_STATIC_CONSTANT(bool, is_integer = limits_type::is_integer);
+ BOOST_STATIC_CONSTANT(bool, is_exact = limits_type::is_exact);
+ BOOST_STATIC_CONSTANT(int, radix = limits_type::radix);
+ static MyInt1 epsilon() throw() { return limits_type::epsilon(); }
+ static MyInt1 round_error() throw() { return limits_type::round_error(); }
+
+ BOOST_STATIC_CONSTANT(int, min_exponent = limits_type::min_exponent);
+ BOOST_STATIC_CONSTANT(int, min_exponent10 = limits_type::min_exponent10);
+ BOOST_STATIC_CONSTANT(int, max_exponent = limits_type::max_exponent);
+ BOOST_STATIC_CONSTANT(int, max_exponent10 = limits_type::max_exponent10);
+
+ BOOST_STATIC_CONSTANT(bool, has_infinity = limits_type::has_infinity);
+ BOOST_STATIC_CONSTANT(bool, has_quiet_NaN = limits_type::has_quiet_NaN);
+ BOOST_STATIC_CONSTANT(bool, has_signaling_NaN = limits_type::has_signaling_NaN);
+ BOOST_STATIC_CONSTANT(float_denorm_style, has_denorm = limits_type::has_denorm);
+ BOOST_STATIC_CONSTANT(bool, has_denorm_loss = limits_type::has_denorm_loss);
+
+ static MyInt1 infinity() throw() { return limits_type::infinity(); }
+ static MyInt1 quiet_NaN() throw() { return limits_type::quiet_NaN(); }
+ static MyInt1 signaling_NaN() throw() {return limits_type::signaling_NaN();}
+ static MyInt1 denorm_min() throw() { return limits_type::denorm_min(); }
+
+ BOOST_STATIC_CONSTANT(bool, is_iec559 = limits_type::is_iec559);
+ BOOST_STATIC_CONSTANT(bool, is_bounded = limits_type::is_bounded);
+ BOOST_STATIC_CONSTANT(bool, is_modulo = limits_type::is_modulo);
+
+ BOOST_STATIC_CONSTANT(bool, traps = limits_type::traps);
+ BOOST_STATIC_CONSTANT(bool, tinyness_before = limits_type::tinyness_before);
+ BOOST_STATIC_CONSTANT(float_round_style, round_style = limits_type::round_style);
+
+}; // std::numeric_limits<MyInt1>
+
+template < >
+class numeric_limits< MyUnsigned1 >
+{
+ typedef MyUnsigned1::int_type int_type;
+ typedef numeric_limits<int_type> limits_type;
+
+public:
+ BOOST_STATIC_CONSTANT(bool, is_specialized = limits_type::is_specialized);
+
+ static MyUnsigned1 min BOOST_NO_MACRO_EXPAND() throw() { return (limits_type::min)(); }
+ static MyUnsigned1 max BOOST_NO_MACRO_EXPAND() throw() { return (limits_type::max)(); }
+
+ BOOST_STATIC_CONSTANT(int, digits = limits_type::digits);
+ BOOST_STATIC_CONSTANT(int, digits10 = limits_type::digits10);
+#ifndef BOOST_NO_CXX11_NUMERIC_LIMITS
+ BOOST_STATIC_CONSTANT(int, max_digits10 = limits_type::max_digits10);
+#endif
+ BOOST_STATIC_CONSTANT(bool, is_signed = limits_type::is_signed);
+ BOOST_STATIC_CONSTANT(bool, is_integer = limits_type::is_integer);
+ BOOST_STATIC_CONSTANT(bool, is_exact = limits_type::is_exact);
+ BOOST_STATIC_CONSTANT(int, radix = limits_type::radix);
+ static MyUnsigned1 epsilon() throw() { return limits_type::epsilon(); }
+ static MyUnsigned1 round_error() throw(){return limits_type::round_error();}
+
+ BOOST_STATIC_CONSTANT(int, min_exponent = limits_type::min_exponent);
+ BOOST_STATIC_CONSTANT(int, min_exponent10 = limits_type::min_exponent10);
+ BOOST_STATIC_CONSTANT(int, max_exponent = limits_type::max_exponent);
+ BOOST_STATIC_CONSTANT(int, max_exponent10 = limits_type::max_exponent10);
+
+ BOOST_STATIC_CONSTANT(bool, has_infinity = limits_type::has_infinity);
+ BOOST_STATIC_CONSTANT(bool, has_quiet_NaN = limits_type::has_quiet_NaN);
+ BOOST_STATIC_CONSTANT(bool, has_signaling_NaN = limits_type::has_signaling_NaN);
+ BOOST_STATIC_CONSTANT(float_denorm_style, has_denorm = limits_type::has_denorm);
+ BOOST_STATIC_CONSTANT(bool, has_denorm_loss = limits_type::has_denorm_loss);
+
+ static MyUnsigned1 infinity() throw() { return limits_type::infinity(); }
+ static MyUnsigned1 quiet_NaN() throw() { return limits_type::quiet_NaN(); }
+ static MyUnsigned1 signaling_NaN() throw()
+ { return limits_type::signaling_NaN(); }
+ static MyUnsigned1 denorm_min() throw(){ return limits_type::denorm_min(); }
+
+ BOOST_STATIC_CONSTANT(bool, is_iec559 = limits_type::is_iec559);
+ BOOST_STATIC_CONSTANT(bool, is_bounded = limits_type::is_bounded);
+ BOOST_STATIC_CONSTANT(bool, is_modulo = limits_type::is_modulo);
+
+ BOOST_STATIC_CONSTANT(bool, traps = limits_type::traps);
+ BOOST_STATIC_CONSTANT(bool, tinyness_before = limits_type::tinyness_before);
+ BOOST_STATIC_CONSTANT(float_round_style, round_style = limits_type::round_style);
+
+}; // std::numeric_limits<MyUnsigned1>
+
+#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
+// MSVC 6.0 lacks operator<< for __int64, see
+// 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
+{
+#ifndef BOOST_MSVC
+ using boost::integer::gcd;
+ using boost::integer::gcd_evaluator;
+#else
+ using namespace boost::integer;
+#endif
+
+ // Originally from Boost.Rational tests
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(1), static_cast<T>(-1)), static_cast<T>( 1) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(-1), static_cast<T>(1)), static_cast<T>( 1) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(1), static_cast<T>(1)), static_cast<T>( 1) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(-1), static_cast<T>(-1)), static_cast<T>( 1) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(0), static_cast<T>(0)), static_cast<T>( 0) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(7), static_cast<T>(0)), static_cast<T>( 7) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(0), static_cast<T>(9)), static_cast<T>( 9) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(-7), static_cast<T>(0)), static_cast<T>( 7) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(0), static_cast<T>(-9)), static_cast<T>( 9) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(42), static_cast<T>(30)), static_cast<T>( 6) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(6), static_cast<T>(-9)), static_cast<T>( 3) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(-10), static_cast<T>(-10)), static_cast<T>(10) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(-25), static_cast<T>(-10)), static_cast<T>( 5) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(3), static_cast<T>(7)), static_cast<T>( 1) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(8), static_cast<T>(9)), static_cast<T>( 1) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(7), static_cast<T>(49)), static_cast<T>( 7) );
+ // Again with function object:
+ BOOST_TEST_EQ(gcd_evaluator<T>()(1, -1), static_cast<T>(1));
+ BOOST_TEST_EQ(gcd_evaluator<T>()(-1, 1), static_cast<T>(1));
+ BOOST_TEST_EQ(gcd_evaluator<T>()(1, 1), static_cast<T>(1));
+ BOOST_TEST_EQ(gcd_evaluator<T>()(-1, -1), static_cast<T>(1));
+ BOOST_TEST_EQ(gcd_evaluator<T>()(0, 0), static_cast<T>(0));
+ BOOST_TEST_EQ(gcd_evaluator<T>()(7, 0), static_cast<T>(7));
+ BOOST_TEST_EQ(gcd_evaluator<T>()(0, 9), static_cast<T>(9));
+ BOOST_TEST_EQ(gcd_evaluator<T>()(-7, 0), static_cast<T>(7));
+ BOOST_TEST_EQ(gcd_evaluator<T>()(0, -9), static_cast<T>(9));
+ BOOST_TEST_EQ(gcd_evaluator<T>()(42, 30), static_cast<T>(6));
+ BOOST_TEST_EQ(gcd_evaluator<T>()(6, -9), static_cast<T>(3));
+ BOOST_TEST_EQ(gcd_evaluator<T>()(-10, -10), static_cast<T>(10));
+ BOOST_TEST_EQ(gcd_evaluator<T>()(-25, -10), static_cast<T>(5));
+ BOOST_TEST_EQ(gcd_evaluator<T>()(3, 7), static_cast<T>(1));
+ BOOST_TEST_EQ(gcd_evaluator<T>()(8, 9), static_cast<T>(1));
+ BOOST_TEST_EQ(gcd_evaluator<T>()(7, 49), static_cast<T>(7));
+}
+
+// GCD on unmarked signed integer type
+void gcd_unmarked_int_test()
+{
+#ifndef BOOST_MSVC
+ using boost::integer::gcd;
+#else
+ using namespace boost::integer;
+#endif
+
+ // The regular signed-integer GCD function performs the unsigned version,
+ // then does an absolute-value on the result. Signed types that are not
+ // marked as such (due to no std::numeric_limits specialization) may be off
+ // by a sign.
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(1), static_cast<MyInt2>(-1) )), MyInt2( 1) );
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(-1), static_cast<MyInt2>(1) )), MyInt2( 1) );
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(1), static_cast<MyInt2>(1) )), MyInt2( 1) );
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(-1), static_cast<MyInt2>(-1) )), MyInt2( 1) );
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(0), static_cast<MyInt2>(0) )), MyInt2( 0) );
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(7), static_cast<MyInt2>(0) )), MyInt2( 7) );
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(0), static_cast<MyInt2>(9) )), MyInt2( 9) );
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(-7), static_cast<MyInt2>(0) )), MyInt2( 7) );
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(0), static_cast<MyInt2>(-9) )), MyInt2( 9) );
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(42), static_cast<MyInt2>(30))), MyInt2( 6) );
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(6), static_cast<MyInt2>(-9) )), MyInt2( 3) );
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(-10), static_cast<MyInt2>(-10) )), MyInt2(10) );
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(-25), static_cast<MyInt2>(-10) )), MyInt2( 5) );
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(3), static_cast<MyInt2>(7) )), MyInt2( 1) );
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(8), static_cast<MyInt2>(9) )), MyInt2( 1) );
+ BOOST_TEST_EQ( abs(boost::integer::gcd(static_cast<MyInt2>(7), static_cast<MyInt2>(49) )), MyInt2( 7) );
+}
+
+// GCD on unsigned integer types
+template< class T > void gcd_unsigned_test() // unsigned_test_types
+{
+#ifndef BOOST_MSVC
+ using boost::integer::gcd;
+#else
+ using namespace boost::integer;
+#endif
+
+ // Note that unmarked types (i.e. have no std::numeric_limits
+ // specialization) are treated like non/unsigned types
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(1u), static_cast<T>(1u)), static_cast<T>( 1u) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(0u), static_cast<T>(0u)), static_cast<T>( 0u) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(7u), static_cast<T>(0u)), static_cast<T>( 7u) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(0u), static_cast<T>(9u)), static_cast<T>( 9u) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(42u), static_cast<T>(30u)), static_cast<T>( 6u) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(3u), static_cast<T>(7u)), static_cast<T>( 1u) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(8u), static_cast<T>(9u)), static_cast<T>( 1u) );
+ BOOST_TEST_EQ( boost::integer::gcd(static_cast<T>(7u), static_cast<T>(49u)), static_cast<T>( 7u) );
+}
+
+// GCD at compile-time
+void gcd_static_test()
+{
+#ifndef BOOST_MSVC
+ using boost::integer::static_gcd;
+#else
+ using namespace boost::integer;
+#endif
+
+ // Can't use "BOOST_TEST_EQ", otherwise the "value" member will be
+ // disqualified as compile-time-only constant, needing explicit definition
+ BOOST_TEST( (static_gcd< 1, 1>::value) == 1 );
+ BOOST_TEST( (static_gcd< 0, 0>::value) == 0 );
+ BOOST_TEST( (static_gcd< 7, 0>::value) == 7 );
+ BOOST_TEST( (static_gcd< 0, 9>::value) == 9 );
+ BOOST_TEST( (static_gcd<42, 30>::value) == 6 );
+ BOOST_TEST( (static_gcd< 3, 7>::value) == 1 );
+ BOOST_TEST( (static_gcd< 8, 9>::value) == 1 );
+ BOOST_TEST( (static_gcd< 7, 49>::value) == 7 );
+}
+
+void gcd_method_test()
+{
+ // Verify that the 3 different methods all yield the same result:
+ boost::random::mt19937 gen;
+ boost::random::uniform_int_distribution<int> d(0, ((std::numeric_limits<int>::max)() / 2));
+
+ for (unsigned int i = 0; i < 10000; ++i)
+ {
+ int v1 = d(gen);
+ int v2 = d(gen);
+ int g = boost::integer::gcd_detail::Euclid_gcd(v1, v2);
+ BOOST_TEST(v1 % g == 0);
+ BOOST_TEST(v2 % g == 0);
+ BOOST_TEST_EQ(g, boost::integer::gcd_detail::mixed_binary_gcd(v1, v2));
+ BOOST_TEST_EQ(g, boost::integer::gcd_detail::Stein_gcd(v1, v2));
+ }
+}
+
+// LCM tests
+
+// LCM on signed integer types
+template< class T > void lcm_int_test() // signed_test_types
+{
+#ifndef BOOST_MSVC
+ using boost::integer::lcm;
+ using boost::integer::lcm_evaluator;
+#else
+ using namespace boost::integer;
+#endif
+
+ // Originally from Boost.Rational tests
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(1), static_cast<T>(-1)), static_cast<T>( 1) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(-1), static_cast<T>(1)), static_cast<T>( 1) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(1), static_cast<T>(1)), static_cast<T>( 1) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(-1), static_cast<T>(-1)), static_cast<T>( 1) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(0), static_cast<T>(0)), static_cast<T>( 0) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(6), static_cast<T>(0)), static_cast<T>( 0) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(0), static_cast<T>(7)), static_cast<T>( 0) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(-5), static_cast<T>(0)), static_cast<T>( 0) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(0), static_cast<T>(-4)), static_cast<T>( 0) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(18), static_cast<T>(30)), static_cast<T>(90) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(-6), static_cast<T>(9)), static_cast<T>(18) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(-10), static_cast<T>(-10)), static_cast<T>(10) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(25), static_cast<T>(-10)), static_cast<T>(50) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(3), static_cast<T>(7)), static_cast<T>(21) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(8), static_cast<T>(9)), static_cast<T>(72) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(7), static_cast<T>(49)), static_cast<T>(49) );
+ // Again with function object:
+ BOOST_TEST_EQ(lcm_evaluator<T>()(1, -1), static_cast<T>(1));
+ BOOST_TEST_EQ(lcm_evaluator<T>()(-1, 1), static_cast<T>(1));
+ BOOST_TEST_EQ(lcm_evaluator<T>()(1, 1), static_cast<T>(1));
+ BOOST_TEST_EQ(lcm_evaluator<T>()(-1, -1), static_cast<T>(1));
+ BOOST_TEST_EQ(lcm_evaluator<T>()(0, 0), static_cast<T>(0));
+ BOOST_TEST_EQ(lcm_evaluator<T>()(6, 0), static_cast<T>(0));
+ BOOST_TEST_EQ(lcm_evaluator<T>()(0, 7), static_cast<T>(0));
+ BOOST_TEST_EQ(lcm_evaluator<T>()(-5, 0), static_cast<T>(0));
+ BOOST_TEST_EQ(lcm_evaluator<T>()(0, -4), static_cast<T>(0));
+ BOOST_TEST_EQ(lcm_evaluator<T>()(18, 30), static_cast<T>(90));
+ BOOST_TEST_EQ(lcm_evaluator<T>()(-6, 9), static_cast<T>(18));
+ BOOST_TEST_EQ(lcm_evaluator<T>()(-10, -10), static_cast<T>(10));
+ BOOST_TEST_EQ(lcm_evaluator<T>()(25, -10), static_cast<T>(50));
+ BOOST_TEST_EQ(lcm_evaluator<T>()(3, 7), static_cast<T>(21));
+ BOOST_TEST_EQ(lcm_evaluator<T>()(8, 9), static_cast<T>(72));
+ BOOST_TEST_EQ(lcm_evaluator<T>()(7, 49), static_cast<T>(49));
+}
+
+// LCM on unmarked signed integer type
+void lcm_unmarked_int_test()
+{
+#ifndef BOOST_MSVC
+ using boost::integer::lcm;
+#else
+ using namespace boost::integer;
+#endif
+
+ // The regular signed-integer LCM function performs the unsigned version,
+ // then does an absolute-value on the result. Signed types that are not
+ // marked as such (due to no std::numeric_limits specialization) may be off
+ // by a sign.
+ BOOST_TEST_EQ( abs(boost::integer::lcm( static_cast<MyInt2>(1), static_cast<MyInt2>(-1) )), MyInt2( 1) );
+ BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(-1), static_cast<MyInt2>(1) )), MyInt2( 1) );
+ BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(1), static_cast<MyInt2>(1) )), MyInt2( 1) );
+ BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(-1), static_cast<MyInt2>(-1) )), MyInt2( 1) );
+ BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(0), static_cast<MyInt2>(0) )), MyInt2( 0) );
+ BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(6), static_cast<MyInt2>(0) )), MyInt2( 0) );
+ BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(0), static_cast<MyInt2>(7) )), MyInt2( 0) );
+ BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(-5), static_cast<MyInt2>(0) )), MyInt2( 0) );
+ BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(0), static_cast<MyInt2>(-4) )), MyInt2( 0) );
+ BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(18), static_cast<MyInt2>(30) )), MyInt2(90) );
+ BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(-6), static_cast<MyInt2>(9) )), MyInt2(18) );
+ BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(-10), static_cast<MyInt2>(-10) )), MyInt2(10) );
+ BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(25), static_cast<MyInt2>(-10) )), MyInt2(50) );
+ BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(3), static_cast<MyInt2>(7) )), MyInt2(21) );
+ BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(8), static_cast<MyInt2>(9) )), MyInt2(72) );
+ BOOST_TEST_EQ( abs(boost::integer::lcm(static_cast<MyInt2>(7), static_cast<MyInt2>(49) )), MyInt2(49) );
+}
+
+// LCM on unsigned integer types
+template< class T > void lcm_unsigned_test() // unsigned_test_types
+{
+#ifndef BOOST_MSVC
+ using boost::integer::lcm;
+#else
+ using namespace boost::integer;
+#endif
+
+ // Note that unmarked types (i.e. have no std::numeric_limits
+ // specialization) are treated like non/unsigned types
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(1u), static_cast<T>(1u)), static_cast<T>( 1u) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(0u), static_cast<T>(0u)), static_cast<T>( 0u) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(6u), static_cast<T>(0u)), static_cast<T>( 0u) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(0u), static_cast<T>(7u)), static_cast<T>( 0u) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(18u), static_cast<T>(30u)), static_cast<T>(90u) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(3u), static_cast<T>(7u)), static_cast<T>(21u) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(8u), static_cast<T>(9u)), static_cast<T>(72u) );
+ BOOST_TEST_EQ( boost::integer::lcm(static_cast<T>(7u), static_cast<T>(49u)), static_cast<T>(49u) );
+}
+
+// LCM at compile-time
+void lcm_static_test()
+{
+#ifndef BOOST_MSVC
+ using boost::integer::static_lcm;
+#else
+ using namespace boost::integer;
+#endif
+
+ // Can't use "BOOST_TEST_EQ", otherwise the "value" member will be
+ // disqualified as compile-time-only constant, needing explicit definition
+ BOOST_TEST( (static_lcm< 1, 1>::value) == 1 );
+ BOOST_TEST( (static_lcm< 0, 0>::value) == 0 );
+ BOOST_TEST( (static_lcm< 6, 0>::value) == 0 );
+ BOOST_TEST( (static_lcm< 0, 7>::value) == 0 );
+ BOOST_TEST( (static_lcm<18, 30>::value) == 90 );
+ BOOST_TEST( (static_lcm< 3, 7>::value) == 21 );
+ BOOST_TEST( (static_lcm< 8, 9>::value) == 72 );
+ BOOST_TEST( (static_lcm< 7, 49>::value) == 49 );
+}
+
+void variadics()
+{
+ unsigned i[] = { 44, 56, 76, 88 };
+ BOOST_TEST_EQ(boost::integer::gcd_range(i, i + 4).first, 4);
+ BOOST_TEST_EQ(boost::integer::gcd_range(i, i + 4).second, i + 4);
+ BOOST_TEST_EQ(boost::integer::lcm_range(i, i + 4).first, 11704);
+ BOOST_TEST_EQ(boost::integer::lcm_range(i, i + 4).second, i + 4);
+#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
+ BOOST_TEST_EQ(boost::integer::gcd(i[0], i[1], i[2], i[3]), 4);
+ BOOST_TEST_EQ(boost::integer::lcm(i[0], i[1], i[2], i[3]), 11704);
+#endif
+}
+
+// Test case from Boost.Rational, need to make sure we don't break the rational lib:
+template <class T> void gcd_and_lcm_on_rationals()
+{
+ typedef boost::rational<T> rational;
+ BOOST_TEST_EQ(boost::integer::gcd(rational(1, 4), rational(1, 3)),
+ rational(1, 12));
+ BOOST_TEST_EQ(boost::integer::lcm(rational(1, 4), rational(1, 3)),
+ rational(1));
+}
+
+#ifndef DISABLE_MP_TESTS
+#define TEST_SIGNED_( test ) \
+ test<signed char>(); \
+ test<short>(); \
+ test<int>(); \
+ test<long>(); \
+ test<MyInt1>(); \
+ test<boost::multiprecision::cpp_int>(); \
+ test<boost::multiprecision::int512_t>();
+#else
+#define TEST_SIGNED_( test ) \
+ test<signed char>(); \
+ test<short>(); \
+ test<int>(); \
+ test<long>(); \
+ test<MyInt1>();
+#endif
+
+#ifdef BOOST_HAS_LONG_LONG
+# define TEST_SIGNED__( test ) \
+ TEST_SIGNED_( test ) \
+ test<boost::long_long_type>();
+#elif defined(BOOST_HAS_MS_INT64)
+# define TEST_SIGNED__( test ) \
+ TEST_SIGNED_( test ) \
+ test<__int64>();
+#endif
+#ifndef DISABLE_MP_TESTS
+#define TEST_UNSIGNED_( test ) \
+ test<unsigned char>(); \
+ test<unsigned short>(); \
+ test<unsigned>(); \
+ test<unsigned long>(); \
+ test<MyUnsigned1>(); \
+ test<MyUnsigned2>(); \
+ test<boost::multiprecision::uint512_t>();
+#else
+#define TEST_UNSIGNED_( test ) \
+ test<unsigned char>(); \
+ test<unsigned short>(); \
+ test<unsigned>(); \
+ test<unsigned long>(); \
+ test<MyUnsigned1>(); \
+ test<MyUnsigned2>();
+#endif
+
+#ifdef BOOST_HAS_LONG_LONG
+# define TEST_UNSIGNED( test ) \
+ TEST_UNSIGNED_( test ) \
+ test<boost::ulong_long_type>();
+#elif defined(BOOST_HAS_MS_INT64)
+# define TEST_UNSIGNED( test ) \
+ TEST_UNSIGNED_( test ) \
+ test<unsigned __int64>();
+#endif
+
+#ifdef BOOST_INTEGER_HAS_GMPXX_H
+# define TEST_SIGNED(test)\
+ TEST_SIGNED__(test)\
+ test<mpz_class>();
+# define TEST_SIGNED_NO_GMP(test) TEST_SIGNED__(test)
+#else
+# define TEST_SIGNED(test) TEST_SIGNED__(test)
+# define TEST_SIGNED_NO_GMP(test) TEST_SIGNED__(test)
+#endif
+
+int main()
+{
+ TEST_SIGNED(gcd_int_test)
+ gcd_unmarked_int_test();
+ TEST_UNSIGNED(gcd_unsigned_test)
+ gcd_static_test();
+ gcd_method_test();
+
+ TEST_SIGNED(lcm_int_test)
+ lcm_unmarked_int_test();
+ TEST_UNSIGNED(lcm_unsigned_test)
+ lcm_static_test();
+ variadics();
+ TEST_SIGNED_NO_GMP(gcd_and_lcm_on_rationals)
+
+ return boost::report_errors();
+}
diff --git a/test/fail_int_exact.cpp b/test/fail_int_exact.cpp
new file mode 100644
index 0000000..1b6e66a
--- /dev/null
+++ b/test/fail_int_exact.cpp
@@ -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;
diff --git a/test/fail_int_fast.cpp b/test/fail_int_fast.cpp
new file mode 100644
index 0000000..8e65b7c
--- /dev/null
+++ b/test/fail_int_fast.cpp
@@ -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;
diff --git a/test/fail_int_least.cpp b/test/fail_int_least.cpp
new file mode 100644
index 0000000..d06ce6d
--- /dev/null
+++ b/test/fail_int_least.cpp
@@ -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;
diff --git a/test/fail_uint_65.cpp b/test/fail_uint_65.cpp
new file mode 100644
index 0000000..76b485e
--- /dev/null
+++ b/test/fail_uint_65.cpp
@@ -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;
+}
diff --git a/test/fail_uint_exact.cpp b/test/fail_uint_exact.cpp
new file mode 100644
index 0000000..36f8628
--- /dev/null
+++ b/test/fail_uint_exact.cpp
@@ -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;
diff --git a/test/fail_uint_fast.cpp b/test/fail_uint_fast.cpp
new file mode 100644
index 0000000..99f92b2
--- /dev/null
+++ b/test/fail_uint_fast.cpp
@@ -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;
diff --git a/test/fail_uint_least.cpp b/test/fail_uint_least.cpp
new file mode 100644
index 0000000..8cdfbaf
--- /dev/null
+++ b/test/fail_uint_least.cpp
@@ -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;
diff --git a/test/gcd_constexpr14_test.cpp b/test/gcd_constexpr14_test.cpp
new file mode 100644
index 0000000..05bef34
--- /dev/null
+++ b/test/gcd_constexpr14_test.cpp
@@ -0,0 +1,66 @@
+
+// (C) Copyright John Maddock 2017.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/integer/common_factor.hpp>
+
+#ifndef BOOST_NO_CXX14_CONSTEXPR
+
+void test_constexpr1()
+{
+ constexpr const boost::int64_t i = 347 * 463 * 727;
+ constexpr const boost::int64_t j = 191 * 347 * 281;
+
+ constexpr const boost::int64_t k = boost::integer::gcd(i, j);
+ constexpr const boost::int64_t l = boost::integer::lcm(i, j);
+
+ static_assert(k == 347, "Expected result not integer in constexpr gcd.");
+ static_assert(l == 6268802158037, "Expected result not integer in constexpr lcm.");
+}
+
+void test_constexpr2()
+{
+ constexpr const boost::uint64_t i = 347 * 463 * 727;
+ constexpr const boost::uint64_t j = 191 * 347 * 281;
+
+ constexpr const boost::uint64_t k = boost::integer::gcd(i, j);
+ constexpr const boost::uint64_t l = boost::integer::lcm(i, j);
+
+ static_assert(k == 347, "Expected result not integer in constexpr gcd.");
+ static_assert(l == 6268802158037, "Expected result not integer in constexpr lcm.");
+}
+
+void test_constexpr3()
+{
+ constexpr const boost::uint64_t i = 347 * 463 * 727;
+ constexpr const boost::uint64_t j = 191 * 347 * 281;
+
+ constexpr const boost::uint64_t k = boost::integer::gcd_detail::Euclid_gcd(i, j);
+
+ static_assert(k == 347, "Expected result not integer in constexpr gcd.");
+}
+
+void test_constexpr4()
+{
+ constexpr const boost::uint64_t i = 347 * 463 * 727;
+ constexpr const boost::uint64_t j = 191 * 347 * 281;
+
+ constexpr const boost::uint64_t k = boost::integer::gcd_detail::mixed_binary_gcd(i, j);
+
+ static_assert(k == 347, "Expected result not integer in constexpr gcd.");
+}
+
+void test_constexpr5()
+{
+ constexpr const boost::uint64_t i = 347 * 463 * 727;
+ constexpr const boost::uint64_t j = 191 * 347 * 281;
+
+ constexpr const boost::uint64_t k = boost::integer::gcd_detail::Stein_gcd(i, j);
+
+ static_assert(k == 347, "Expected result not integer in constexpr gcd.");
+}
+#endif
+
+
diff --git a/test/gcd_noexcept_test.cpp b/test/gcd_noexcept_test.cpp
new file mode 100644
index 0000000..9100744
--- /dev/null
+++ b/test/gcd_noexcept_test.cpp
@@ -0,0 +1,35 @@
+
+// (C) Copyright John Maddock 2017.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/integer/common_factor.hpp>
+
+#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
+//
+// These tests don't pass with GCC-4.x:
+//
+#if !defined(BOOST_GCC) || (BOOST_GCC >= 50000)
+
+void test_noexcept(unsigned char a, unsigned char b)
+{
+ static_assert(noexcept(boost::integer::gcd(static_cast<unsigned char>(a), static_cast<unsigned char>(b))), "Expected a noexcept function.");
+#ifndef _MSC_VER
+ // This generates an internal compiler error if enabled as well as the following test:
+ static_assert(noexcept(boost::integer::gcd(static_cast<char>(a), static_cast<char>(b))), "Expected a noexcept function.");
+#endif
+ static_assert(noexcept(boost::integer::gcd(static_cast<signed char>(a), static_cast<signed char>(b))), "Expected a noexcept function.");
+ static_assert(noexcept(boost::integer::gcd(static_cast<short>(a), static_cast<short>(b))), "Expected a noexcept function.");
+ static_assert(noexcept(boost::integer::gcd(static_cast<unsigned short>(a), static_cast<unsigned short>(b))), "Expected a noexcept function.");
+ static_assert(noexcept(boost::integer::gcd(static_cast<int>(a), static_cast<int>(b))), "Expected a noexcept function.");
+ static_assert(noexcept(boost::integer::gcd(static_cast<unsigned int>(a), static_cast<unsigned int>(b))), "Expected a noexcept function.");
+ static_assert(noexcept(boost::integer::gcd(static_cast<long>(a), static_cast<long>(b))), "Expected a noexcept function.");
+ static_assert(noexcept(boost::integer::gcd(static_cast<unsigned long>(a), static_cast<unsigned long>(b))), "Expected a noexcept function.");
+ static_assert(noexcept(boost::integer::gcd(static_cast<long long>(a), static_cast<long long>(b))), "Expected a noexcept function.");
+ static_assert(noexcept(boost::integer::gcd(static_cast<unsigned long long>(a), static_cast<unsigned long long>(b))), "Expected a noexcept function.");
+}
+
+#endif
+#endif
+
diff --git a/test/has_gmpxx.cpp b/test/has_gmpxx.cpp
new file mode 100644
index 0000000..edf62d8
--- /dev/null
+++ b/test/has_gmpxx.cpp
@@ -0,0 +1,7 @@
+// Copyright John Maddock 2008.
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <gmpxx.h>
+
diff --git a/test/integer_fwd_include_test.cpp b/test/integer_fwd_include_test.cpp
new file mode 100644
index 0000000..4346b69
--- /dev/null
+++ b/test/integer_fwd_include_test.cpp
@@ -0,0 +1,22 @@
+// Copyright John Maddock 2009.
+// Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/integer_fwd.hpp> // must be the only #include!
+
+// just declare some functions that use the incomplete types in the header:
+
+void f1(const boost::integer_traits<char>*);
+void f2(const boost::int_fast_t<char>*);
+void f3(const boost::int_t<12>*);
+void f4(const boost::uint_t<31>*);
+void f5(const boost::int_max_value_t<100>*);
+void f6(const boost::int_min_value_t<-100>*);
+void f7(const boost::uint_value_t<100>*);
+void f8(const boost::high_bit_mask_t<10>*);
+void f9(const boost::low_bits_mask_t<10>*);
+void f10(boost::static_log2_argument_type, boost::static_log2_result_type, boost::static_log2<10>*);
+void f11(boost::static_min_max_signed_type, boost::static_min_max_unsigned_type);
+void f12(boost::static_signed_min<1, 2>*, boost::static_signed_max<1,2>*);
+void f13(boost::static_unsigned_min<1,2>*, boost::static_unsigned_min<1,2>*);
diff --git a/test/integer_include_test.cpp b/test/integer_include_test.cpp
new file mode 100644
index 0000000..653a197
--- /dev/null
+++ b/test/integer_include_test.cpp
@@ -0,0 +1,36 @@
+// Copyright John Maddock 2009.
+// Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/integer.hpp> // must be the only #include!
+
+int main()
+{
+ boost::int_fast_t<char>::fast f = 0;
+ (void)f;
+ boost::int_t<16>::fast f2 = 0;
+ (void)f2;
+ boost::int_t<32>::exact e = 0;
+ (void)e;
+ boost::int_t<12>::least l = 0;
+ (void)l;
+ boost::uint_t<16>::fast uf2 = 0;
+ (void)uf2;
+ boost::uint_t<32>::exact ue = 0;
+ (void)ue;
+ boost::uint_t<12>::least ul = 0;
+ (void)ul;
+ boost::int_max_value_t<200>::fast v1 = 0;
+ (void)v1;
+ boost::int_max_value_t<2000>::least v2 = 0;
+ (void)v2;
+ boost::int_min_value_t<-200>::fast v3 = 0;
+ (void)v3;
+ boost::int_min_value_t<-2000>::least v4 = 0;
+ (void)v4;
+ boost::uint_value_t<200>::fast v5 = 0;
+ (void)v5;
+ boost::uint_value_t<2000>::least v6 = 0;
+ (void)v6;
+}
diff --git a/test/integer_mask_include_test.cpp b/test/integer_mask_include_test.cpp
new file mode 100644
index 0000000..09af189
--- /dev/null
+++ b/test/integer_mask_include_test.cpp
@@ -0,0 +1,18 @@
+// Copyright John Maddock 2009.
+// Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/integer/integer_mask.hpp> // must be the only #include!
+
+int main()
+{
+ boost::high_bit_mask_t<20>::least l = boost::high_bit_mask_t<20>::high_bit;
+ boost::high_bit_mask_t<12>::fast f = boost::high_bit_mask_t<12>::high_bit_fast;
+ l += f + boost::high_bit_mask_t<12>::bit_position;
+ (void)l;
+ boost::low_bits_mask_t<20>::least l2 = boost::low_bits_mask_t<20>::sig_bits;
+ boost::low_bits_mask_t<12>::fast f2 = boost::low_bits_mask_t<12>::sig_bits_fast;
+ l2 += f2 + boost::low_bits_mask_t<12>::bit_count;
+ (void)l2;
+}
diff --git a/test/integer_mask_test.cpp b/test/integer_mask_test.cpp
new file mode 100644
index 0000000..a66ab8d
--- /dev/null
+++ b/test/integer_mask_test.cpp
@@ -0,0 +1,203 @@
+// boost integer_mask.hpp test program -------------------------------------//
+
+// (C) Copyright Daryle Walker 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 for most recent version including documentation.
+
+// Revision History
+// 23 Sep 2001 Initial version (Daryle Walker)
+
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/cstdlib.hpp> // for boost::exit_success
+#include <boost/integer/integer_mask.hpp> // for boost::high_bit_mask_t, etc.
+
+#include <iostream> // for std::cout (std::endl indirectly)
+
+#ifdef BOOST_MSVC
+#pragma warning(disable:4127) // conditional expression is constant
+#endif
+
+#if defined(BOOST_HAS_LONG_LONG)
+#define MASK_TYPE ::boost::ulong_long_type
+#elif defined(BOOST_HAS_MS_INT64)
+#define MASK_TYPE unsigned __int64
+#else
+#define MASK_TYPE unsigned long
+#endif
+
+#define ONE (static_cast<MASK_TYPE>(1))
+
+#define PRIVATE_HIGH_BIT_SLOW_TEST(v) BOOST_TEST( ::boost::high_bit_mask_t< \
+ (v) >::high_bit == (ONE << (v)) );
+#define PRIVATE_HIGH_BIT_FAST_TEST(v) BOOST_TEST( ::boost::high_bit_mask_t< \
+ (v) >::high_bit_fast == (ONE << (v)) );
+#define PRIVATE_HIGH_BIT_TEST(v) do { PRIVATE_HIGH_BIT_SLOW_TEST(v); \
+ PRIVATE_HIGH_BIT_FAST_TEST(v); } while (false)
+
+#define PRIVATE_LOW_BITS_SLOW_TEST(v) \
+ do{ \
+ MASK_TYPE mask = 0;\
+ if(v > 0)\
+ { mask = ((ONE << (v-1)) - 1); mask <<= 1; mask |= 1; }\
+ BOOST_TEST( ::boost::low_bits_mask_t< (v) >::sig_bits == mask); \
+ }while(false);
+#define PRIVATE_LOW_BITS_FAST_TEST(v) \
+ do{ \
+ MASK_TYPE mask = 0;\
+ if(v > 0)\
+ { mask = ((ONE << (v-1)) - 1); mask <<= 1; mask |= 1; }\
+ BOOST_TEST( ::boost::low_bits_mask_t< (v) >::sig_bits_fast == mask);\
+ }while(false);
+#define PRIVATE_LOW_BITS_TEST(v) do { PRIVATE_LOW_BITS_SLOW_TEST(v); \
+ PRIVATE_LOW_BITS_FAST_TEST(v); } while (false)
+
+
+int main( int, char*[] )
+{
+ using std::cout;
+ using std::endl;
+
+ cout << "Doing high_bit_mask_t tests." << endl;
+
+#if defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)
+ PRIVATE_HIGH_BIT_TEST( 63 );
+ PRIVATE_HIGH_BIT_TEST( 62 );
+ PRIVATE_HIGH_BIT_TEST( 61 );
+ PRIVATE_HIGH_BIT_TEST( 60 );
+ PRIVATE_HIGH_BIT_TEST( 59 );
+ PRIVATE_HIGH_BIT_TEST( 58 );
+ PRIVATE_HIGH_BIT_TEST( 57 );
+ PRIVATE_HIGH_BIT_TEST( 56 );
+ PRIVATE_HIGH_BIT_TEST( 55 );
+ PRIVATE_HIGH_BIT_TEST( 54 );
+ PRIVATE_HIGH_BIT_TEST( 53 );
+ PRIVATE_HIGH_BIT_TEST( 52 );
+ PRIVATE_HIGH_BIT_TEST( 51 );
+ PRIVATE_HIGH_BIT_TEST( 50 );
+ PRIVATE_HIGH_BIT_TEST( 49 );
+ PRIVATE_HIGH_BIT_TEST( 48 );
+ PRIVATE_HIGH_BIT_TEST( 47 );
+ PRIVATE_HIGH_BIT_TEST( 46 );
+ PRIVATE_HIGH_BIT_TEST( 45 );
+ PRIVATE_HIGH_BIT_TEST( 44 );
+ PRIVATE_HIGH_BIT_TEST( 43 );
+ PRIVATE_HIGH_BIT_TEST( 42 );
+ PRIVATE_HIGH_BIT_TEST( 41 );
+ PRIVATE_HIGH_BIT_TEST( 40 );
+ PRIVATE_HIGH_BIT_TEST( 39 );
+ PRIVATE_HIGH_BIT_TEST( 38 );
+ PRIVATE_HIGH_BIT_TEST( 37 );
+ PRIVATE_HIGH_BIT_TEST( 36 );
+ PRIVATE_HIGH_BIT_TEST( 35 );
+ PRIVATE_HIGH_BIT_TEST( 34 );
+ PRIVATE_HIGH_BIT_TEST( 33 );
+ PRIVATE_HIGH_BIT_TEST( 32 );
+#endif
+ PRIVATE_HIGH_BIT_TEST( 31 );
+ PRIVATE_HIGH_BIT_TEST( 30 );
+ PRIVATE_HIGH_BIT_TEST( 29 );
+ PRIVATE_HIGH_BIT_TEST( 28 );
+ PRIVATE_HIGH_BIT_TEST( 27 );
+ PRIVATE_HIGH_BIT_TEST( 26 );
+ PRIVATE_HIGH_BIT_TEST( 25 );
+ PRIVATE_HIGH_BIT_TEST( 24 );
+ PRIVATE_HIGH_BIT_TEST( 23 );
+ PRIVATE_HIGH_BIT_TEST( 22 );
+ PRIVATE_HIGH_BIT_TEST( 21 );
+ PRIVATE_HIGH_BIT_TEST( 20 );
+ PRIVATE_HIGH_BIT_TEST( 19 );
+ PRIVATE_HIGH_BIT_TEST( 18 );
+ PRIVATE_HIGH_BIT_TEST( 17 );
+ PRIVATE_HIGH_BIT_TEST( 16 );
+ PRIVATE_HIGH_BIT_TEST( 15 );
+ PRIVATE_HIGH_BIT_TEST( 14 );
+ PRIVATE_HIGH_BIT_TEST( 13 );
+ PRIVATE_HIGH_BIT_TEST( 12 );
+ PRIVATE_HIGH_BIT_TEST( 11 );
+ PRIVATE_HIGH_BIT_TEST( 10 );
+ PRIVATE_HIGH_BIT_TEST( 9 );
+ PRIVATE_HIGH_BIT_TEST( 8 );
+ PRIVATE_HIGH_BIT_TEST( 7 );
+ PRIVATE_HIGH_BIT_TEST( 6 );
+ PRIVATE_HIGH_BIT_TEST( 5 );
+ PRIVATE_HIGH_BIT_TEST( 4 );
+ PRIVATE_HIGH_BIT_TEST( 3 );
+ PRIVATE_HIGH_BIT_TEST( 2 );
+ PRIVATE_HIGH_BIT_TEST( 1 );
+ PRIVATE_HIGH_BIT_TEST( 0 );
+
+ cout << "Doing low_bits_mask_t tests." << endl;
+
+#if defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)
+ PRIVATE_LOW_BITS_TEST( 64 );
+ PRIVATE_LOW_BITS_TEST( 63 );
+ PRIVATE_LOW_BITS_TEST( 62 );
+ PRIVATE_LOW_BITS_TEST( 61 );
+ PRIVATE_LOW_BITS_TEST( 60 );
+ PRIVATE_LOW_BITS_TEST( 59 );
+ PRIVATE_LOW_BITS_TEST( 58 );
+ PRIVATE_LOW_BITS_TEST( 57 );
+ PRIVATE_LOW_BITS_TEST( 56 );
+ PRIVATE_LOW_BITS_TEST( 55 );
+ PRIVATE_LOW_BITS_TEST( 54 );
+ PRIVATE_LOW_BITS_TEST( 53 );
+ PRIVATE_LOW_BITS_TEST( 52 );
+ PRIVATE_LOW_BITS_TEST( 51 );
+ PRIVATE_LOW_BITS_TEST( 50 );
+ PRIVATE_LOW_BITS_TEST( 49 );
+ PRIVATE_LOW_BITS_TEST( 48 );
+ PRIVATE_LOW_BITS_TEST( 47 );
+ PRIVATE_LOW_BITS_TEST( 46 );
+ PRIVATE_LOW_BITS_TEST( 45 );
+ PRIVATE_LOW_BITS_TEST( 44 );
+ PRIVATE_LOW_BITS_TEST( 43 );
+ PRIVATE_LOW_BITS_TEST( 42 );
+ PRIVATE_LOW_BITS_TEST( 41 );
+ PRIVATE_LOW_BITS_TEST( 40 );
+ PRIVATE_LOW_BITS_TEST( 39 );
+ PRIVATE_LOW_BITS_TEST( 38 );
+ PRIVATE_LOW_BITS_TEST( 37 );
+ PRIVATE_LOW_BITS_TEST( 36 );
+ PRIVATE_LOW_BITS_TEST( 35 );
+ PRIVATE_LOW_BITS_TEST( 34 );
+ PRIVATE_LOW_BITS_TEST( 33 );
+#endif
+ PRIVATE_LOW_BITS_TEST( 32 );
+ PRIVATE_LOW_BITS_TEST( 31 );
+ PRIVATE_LOW_BITS_TEST( 30 );
+ PRIVATE_LOW_BITS_TEST( 29 );
+ PRIVATE_LOW_BITS_TEST( 28 );
+ PRIVATE_LOW_BITS_TEST( 27 );
+ PRIVATE_LOW_BITS_TEST( 26 );
+ PRIVATE_LOW_BITS_TEST( 25 );
+ PRIVATE_LOW_BITS_TEST( 24 );
+ PRIVATE_LOW_BITS_TEST( 23 );
+ PRIVATE_LOW_BITS_TEST( 22 );
+ PRIVATE_LOW_BITS_TEST( 21 );
+ PRIVATE_LOW_BITS_TEST( 20 );
+ PRIVATE_LOW_BITS_TEST( 19 );
+ PRIVATE_LOW_BITS_TEST( 18 );
+ PRIVATE_LOW_BITS_TEST( 17 );
+ PRIVATE_LOW_BITS_TEST( 16 );
+ PRIVATE_LOW_BITS_TEST( 15 );
+ PRIVATE_LOW_BITS_TEST( 14 );
+ PRIVATE_LOW_BITS_TEST( 13 );
+ PRIVATE_LOW_BITS_TEST( 12 );
+ PRIVATE_LOW_BITS_TEST( 11 );
+ PRIVATE_LOW_BITS_TEST( 10 );
+ PRIVATE_LOW_BITS_TEST( 9 );
+ PRIVATE_LOW_BITS_TEST( 8 );
+ PRIVATE_LOW_BITS_TEST( 7 );
+ PRIVATE_LOW_BITS_TEST( 6 );
+ PRIVATE_LOW_BITS_TEST( 5 );
+ PRIVATE_LOW_BITS_TEST( 4 );
+ PRIVATE_LOW_BITS_TEST( 3 );
+ PRIVATE_LOW_BITS_TEST( 2 );
+ PRIVATE_LOW_BITS_TEST( 1 );
+
+ return boost::report_errors();
+}
diff --git a/test/integer_test.cpp b/test/integer_test.cpp
new file mode 100644
index 0000000..a79db2d
--- /dev/null
+++ b/test/integer_test.cpp
@@ -0,0 +1,264 @@
+// boost integer.hpp test program ------------------------------------------//
+
+// Copyright Beman Dawes 1999.
+// Copyright Daryle Walker 2001.
+// Copyright John Maddock 2009.
+// Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+
+// See http://www.boost.org/libs/integer for documentation.
+
+// Revision History
+// 04 Oct 01 Added tests for new templates; rewrote code (Daryle Walker)
+// 10 Mar 01 Boost Test Library now used for tests (Beman Dawes)
+// 31 Aug 99 Initial version
+
+#include <boost/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)
+#include <typeinfo> // for std::type_info
+
+#ifdef BOOST_MSVC
+#pragma warning(disable:4127) // conditional expression is constant
+#endif
+#if defined( __BORLANDC__ )
+# pragma option -w-8008 -w-8066 // condition is always true
+#endif
+
+//
+// Keep track of error count, so we can print out detailed
+// info only if we need it:
+//
+int last_error_count = 0;
+//
+// Helpers to print out the name of a type,
+// we use these as typeid(X).name() doesn't always
+// return a human readable string:
+//
+template <class T> const char* get_name_of_type(T){ return typeid(T).name(); }
+const char* get_name_of_type(signed char){ return "signed char"; }
+const char* get_name_of_type(unsigned char){ return "unsigned char"; }
+const char* get_name_of_type(short){ return "short"; }
+const char* get_name_of_type(unsigned short){ return "unsigned short"; }
+const char* get_name_of_type(int){ return "int"; }
+const char* get_name_of_type(unsigned int){ return "unsigned int"; }
+const char* get_name_of_type(long){ return "long"; }
+const char* get_name_of_type(unsigned long){ return "unsigned long"; }
+#ifdef BOOST_HAS_LONG_LONG
+const char* get_name_of_type(boost::long_long_type){ return "boost::long_long_type"; }
+const char* get_name_of_type(boost::ulong_long_type){ return "boost::ulong_long_type"; }
+#endif
+
+template <int Bits>
+void do_test_exact(boost::mpl::true_ const&)
+{
+ // Test the ::exact member:
+ typedef typename boost::int_t<Bits>::exact int_exact;
+ typedef typename boost::uint_t<Bits>::exact uint_exact;
+ typedef typename boost::int_t<Bits>::least least_int;
+ typedef typename boost::uint_t<Bits>::least least_uint;
+
+ BOOST_TEST((boost::is_same<int_exact, least_int>::value));
+ BOOST_TEST((boost::is_same<uint_exact, least_uint>::value));
+}
+template <int Bits>
+void do_test_exact(boost::mpl::false_ const&)
+{
+ // Nothing to do, type does not have an ::extact member.
+}
+
+template <int Bits>
+void do_test_bits()
+{
+ //
+ // Recurse to next smallest number of bits:
+ //
+ do_test_bits<Bits - 1>();
+ //
+ // Test exact types if we have them:
+ //
+ do_test_exact<Bits>(
+ boost::mpl::bool_<
+ (sizeof(unsigned char) * CHAR_BIT == Bits)
+ || (sizeof(unsigned short) * CHAR_BIT == Bits)
+ || (sizeof(unsigned int) * CHAR_BIT == Bits)
+ || (sizeof(unsigned long) * CHAR_BIT == Bits)
+#ifdef BOOST_HAS_LONG_LONG
+ || (sizeof(boost::ulong_long_type) * CHAR_BIT == Bits)
+#endif
+ >());
+ //
+ // We need to check all aspects of the members of int_t<Bits> and uint_t<Bits>:
+ //
+ typedef typename boost::int_t<Bits>::least least_int;
+ typedef typename boost::int_t<Bits>::least fast_int;
+ typedef typename boost::uint_t<Bits>::least least_uint;
+ typedef typename boost::uint_t<Bits>::fast fast_uint;
+
+ if(std::numeric_limits<least_int>::is_specialized)
+ {
+ BOOST_TEST(std::numeric_limits<least_int>::digits + 1 >= Bits);
+ }
+ if(std::numeric_limits<least_uint>::is_specialized)
+ {
+ BOOST_TEST(std::numeric_limits<least_uint>::digits >= Bits);
+ }
+ BOOST_TEST(sizeof(least_int) * CHAR_BIT >= Bits);
+ BOOST_TEST(sizeof(least_uint) * CHAR_BIT >= Bits);
+ BOOST_TEST(sizeof(fast_int) >= sizeof(least_int));
+ BOOST_TEST(sizeof(fast_uint) >= sizeof(least_uint));
+ //
+ // There should be no type smaller than least_* that also has enough bits:
+ //
+ if(!boost::is_same<signed char, least_int>::value)
+ {
+ BOOST_TEST(std::numeric_limits<signed char>::digits < Bits);
+ if(!boost::is_same<short, least_int>::value)
+ {
+ BOOST_TEST(std::numeric_limits<short>::digits < Bits);
+ if(!boost::is_same<int, least_int>::value)
+ {
+ BOOST_TEST(std::numeric_limits<int>::digits < Bits);
+ if(!boost::is_same<long, least_int>::value)
+ {
+ BOOST_TEST(std::numeric_limits<long>::digits < Bits);
+ }
+ }
+ }
+ }
+ // And again, but unsigned:
+ if(!boost::is_same<unsigned char, least_uint>::value)
+ {
+ BOOST_TEST(std::numeric_limits<unsigned char>::digits < Bits);
+ if(!boost::is_same<unsigned short, least_uint>::value)
+ {
+ BOOST_TEST(std::numeric_limits<unsigned short>::digits < Bits);
+ if(!boost::is_same<unsigned int, least_uint>::value)
+ {
+ BOOST_TEST(std::numeric_limits<unsigned int>::digits < Bits);
+ if(!boost::is_same<unsigned long, least_uint>::value)
+ {
+ BOOST_TEST(std::numeric_limits<unsigned long>::digits < Bits);
+ }
+ }
+ }
+ }
+
+ if(boost::detail::test_errors() != last_error_count)
+ {
+ last_error_count = boost::detail::test_errors();
+ std::cout << "Errors occurred while testing with bit count = " << Bits << std::endl;
+ std::cout << "Type int_t<" << Bits << ">::least was " << get_name_of_type(least_int(0)) << std::endl;
+ std::cout << "Type int_t<" << Bits << ">::fast was " << get_name_of_type(fast_int(0)) << std::endl;
+ std::cout << "Type uint_t<" << Bits << ">::least was " << get_name_of_type(least_uint(0)) << std::endl;
+ std::cout << "Type uint_t<" << Bits << ">::fast was " << get_name_of_type(fast_uint(0)) << std::endl;
+ }
+}
+template <>
+void do_test_bits<-1>()
+{
+ // Nothing to do here!!
+}
+
+template <class Traits, class Expected>
+void test_min_max_type(Expected val)
+{
+ typedef typename Traits::least least_type;
+ typedef typename Traits::fast fast_type;
+ BOOST_TEST((boost::is_same<least_type, Expected>::value));
+ BOOST_TEST(sizeof(fast_type) >= sizeof(least_type));
+ BOOST_TEST((std::numeric_limits<least_type>::min)() <= val);
+ BOOST_TEST((std::numeric_limits<least_type>::max)() >= val);
+
+ if(boost::detail::test_errors() != last_error_count)
+ {
+ last_error_count = boost::detail::test_errors();
+ std::cout << "Traits type is: " << typeid(Traits).name() << std::endl;
+ std::cout << "Least type is: " << get_name_of_type(least_type(0)) << std::endl;
+ std::cout << "Fast type is: " << get_name_of_type(fast_type(0)) << std::endl;
+ std::cout << "Expected type is: " << get_name_of_type(Expected(0)) << std::endl;
+ std::cout << "Required value is: " << val << std::endl;
+ }
+}
+
+// Test program
+int main(int, char*[])
+{
+ // Test int_t and unint_t first:
+ if(std::numeric_limits<boost::intmax_t>::is_specialized)
+ do_test_bits<std::numeric_limits<boost::uintmax_t>::digits>();
+ else
+ do_test_bits<std::numeric_limits<long>::digits>();
+
+ //
+ // Test min and max value types:
+ //
+ test_min_max_type<boost::int_max_value_t<SCHAR_MAX>, signed char>(SCHAR_MAX);
+ test_min_max_type<boost::int_min_value_t<SCHAR_MIN>, signed char>(SCHAR_MIN);
+ test_min_max_type<boost::uint_value_t<UCHAR_MAX>, unsigned char>(UCHAR_MAX);
+#if(USHRT_MAX != UCHAR_MAX)
+ test_min_max_type<boost::int_max_value_t<SCHAR_MAX+1>, short>(SCHAR_MAX+1);
+ test_min_max_type<boost::int_min_value_t<SCHAR_MIN-1>, short>(SCHAR_MIN-1);
+ test_min_max_type<boost::uint_value_t<UCHAR_MAX+1>, unsigned short>(UCHAR_MAX+1);
+ test_min_max_type<boost::int_max_value_t<SHRT_MAX>, short>(SHRT_MAX);
+ test_min_max_type<boost::int_min_value_t<SHRT_MIN>, short>(SHRT_MIN);
+ test_min_max_type<boost::uint_value_t<USHRT_MAX>, unsigned short>(USHRT_MAX);
+#endif
+#if(UINT_MAX != USHRT_MAX)
+ test_min_max_type<boost::int_max_value_t<SHRT_MAX+1>, int>(SHRT_MAX+1);
+ test_min_max_type<boost::int_min_value_t<SHRT_MIN-1>, int>(SHRT_MIN-1);
+ test_min_max_type<boost::uint_value_t<USHRT_MAX+1>, unsigned int>(USHRT_MAX+1);
+ test_min_max_type<boost::int_max_value_t<INT_MAX>, int>(INT_MAX);
+ test_min_max_type<boost::int_min_value_t<INT_MIN>, int>(INT_MIN);
+ test_min_max_type<boost::uint_value_t<UINT_MAX>, unsigned int>(UINT_MAX);
+#endif
+#if(ULONG_MAX != UINT_MAX)
+ test_min_max_type<boost::int_max_value_t<INT_MAX+1L>, long>(INT_MAX+1L);
+ test_min_max_type<boost::int_min_value_t<INT_MIN-1L>, long>(INT_MIN-1L);
+ test_min_max_type<boost::uint_value_t<UINT_MAX+1uL>, unsigned long>(UINT_MAX+1uL);
+ test_min_max_type<boost::int_max_value_t<LONG_MAX>, long>(LONG_MAX);
+ test_min_max_type<boost::int_min_value_t<LONG_MIN>, long>(LONG_MIN);
+ test_min_max_type<boost::uint_value_t<ULONG_MAX>, unsigned long>(ULONG_MAX);
+#endif
+#ifndef BOOST_NO_INTEGRAL_INT64_T
+#if defined(BOOST_HAS_LONG_LONG) && (defined(ULLONG_MAX) && (ULLONG_MAX != ULONG_MAX))
+ test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, boost::long_long_type>(LONG_MAX+1LL);
+ test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, boost::long_long_type>(LONG_MIN-1LL);
+ test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, boost::ulong_long_type>(ULONG_MAX+1uLL);
+ test_min_max_type<boost::int_max_value_t<LLONG_MAX>, boost::long_long_type>(LLONG_MAX);
+ test_min_max_type<boost::int_min_value_t<LLONG_MIN>, boost::long_long_type>(LLONG_MIN);
+ test_min_max_type<boost::uint_value_t<ULLONG_MAX>, boost::ulong_long_type>(ULLONG_MAX);
+#endif
+#if defined(BOOST_HAS_LONG_LONG) && (defined(ULONG_LONG_MAX) && (ULONG_LONG_MAX != ULONG_MAX))
+ test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, boost::long_long_type>(LONG_MAX+1LL);
+ test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, boost::long_long_type>(LONG_MIN-1LL);
+ test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, boost::ulong_long_type>(ULONG_MAX+1uLL);
+ test_min_max_type<boost::int_max_value_t<LONG_LONG_MAX>, boost::long_long_type>(LONG_LONG_MAX);
+ test_min_max_type<boost::int_min_value_t<LONG_LONG_MIN>, boost::long_long_type>(LONG_LONG_MIN);
+ test_min_max_type<boost::uint_value_t<ULONG_LONG_MAX>, boost::ulong_long_type>(ULONG_LONG_MAX);
+#endif
+#if defined(BOOST_HAS_LONG_LONG) && (defined(ULONGLONG_MAX) && (ULONGLONG_MAX != ULONG_MAX))
+ test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, boost::long_long_type>(LONG_MAX+1LL);
+ test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, boost::long_long_type>(LONG_MIN-1LL);
+ test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, boost::ulong_long_type>(ULONG_MAX+1uLL);
+ test_min_max_type<boost::int_max_value_t<LONGLONG_MAX>, boost::long_long_type>(LONGLONG_MAX);
+ test_min_max_type<boost::int_min_value_t<LONGLONG_MIN>, boost::long_long_type>(LONGLONG_MAX);
+ test_min_max_type<boost::uint_value_t<ULONGLONG_MAX>, boost::ulong_long_type>(ULONGLONG_MAX);
+#endif
+#if defined(BOOST_HAS_LONG_LONG) && (defined(_ULLONG_MAX) && defined(_LLONG_MIN) && (_ULLONG_MAX != ULONG_MAX))
+ test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, boost::long_long_type>(LONG_MAX+1LL);
+ test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, boost::long_long_type>(LONG_MIN-1LL);
+ test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, boost::ulong_long_type>(ULONG_MAX+1uLL);
+ test_min_max_type<boost::int_max_value_t<_LLONG_MAX>, boost::long_long_type>(_LLONG_MAX);
+ test_min_max_type<boost::int_min_value_t<_LLONG_MIN>, boost::long_long_type>(_LLONG_MIN);
+ test_min_max_type<boost::uint_value_t<_ULLONG_MAX>, boost::ulong_long_type>(_ULLONG_MAX);
+#endif // BOOST_HAS_LONG_LONG
+#endif // BOOST_NO_INTEGRAL_INT64_T
+ return boost::report_errors();
+}
diff --git a/test/integer_traits_include_test.cpp b/test/integer_traits_include_test.cpp
new file mode 100644
index 0000000..a71fb33
--- /dev/null
+++ b/test/integer_traits_include_test.cpp
@@ -0,0 +1,37 @@
+// Copyright John Maddock 2009.
+// Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/integer_traits.hpp> // must be the only #include!
+
+template <class T>
+void check_numeric_limits_derived(const std::numeric_limits<T>&){}
+
+template <class T>
+void check()
+{
+ typedef boost::integer_traits<T> traits;
+ check_numeric_limits_derived(traits());
+ bool b = traits::is_integral;
+ (void)b;
+ T v = traits::const_min + traits::const_max;
+ (void)v;
+}
+
+int main()
+{
+ check<signed char>();
+ check<unsigned char>();
+ check<char>();
+ check<short>();
+ check<unsigned short>();
+ check<int>();
+ check<unsigned int>();
+ check<signed long>();
+ check<unsigned long>();
+#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
+ check<boost::long_long_type>();
+ check<boost::ulong_long_type>();
+#endif
+}
diff --git a/test/integer_traits_test.cpp b/test/integer_traits_test.cpp
new file mode 100644
index 0000000..b6e0d49
--- /dev/null
+++ b/test/integer_traits_test.cpp
@@ -0,0 +1,101 @@
+/* boost integer_traits.hpp tests
+ *
+ * Copyright Jens Maurer 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)
+ *
+ * $Id$
+ *
+ * Revision history
+ * 2000-02-22 Small improvements by Beman Dawes
+ * 2000-06-27 Rework for better MSVC and BCC co-operation
+ */
+
+#include <iostream>
+#include <boost/integer_traits.hpp>
+// use int64_t instead of long long for better portability
+#include <boost/cstdint.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+/*
+ * General portability note:
+ * MSVC mis-compiles explicit function template instantiations.
+ * For example, f<A>() and f<B>() are both compiled to call f<A>().
+ * BCC is unable to implicitly convert a "const char *" to a std::string
+ * when using explicit function template instantiations.
+ *
+ * Therefore, avoid explicit function template instantiations.
+ */
+
+#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)
+template<typename T> inline T make_char_numeric_for_streaming(T x) { return x; }
+namespace fix{
+inline int make_char_numeric_for_streaming(char c) { return c; }
+inline int make_char_numeric_for_streaming(signed char c) { return c; }
+inline int make_char_numeric_for_streaming(unsigned char c) { return c; }
+}
+using namespace fix;
+#else
+template<typename T> inline T make_char_numeric_for_streaming(T x) { return x; }
+inline int make_char_numeric_for_streaming(char c) { return c; }
+inline int make_char_numeric_for_streaming(signed char c) { return c; }
+inline int make_char_numeric_for_streaming(unsigned char c) { return c; }
+#endif
+
+template<class T>
+void runtest(const char * type, T)
+{
+ typedef boost::integer_traits<T> traits;
+ std::cout << "Checking " << type
+ << "; min is " << make_char_numeric_for_streaming((traits::min)())
+ << ", max is " << make_char_numeric_for_streaming((traits::max)())
+ << std::endl;
+ BOOST_TEST(traits::is_specialized);
+#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1200)
+ // MSVC++ 6.0 issues a LNK1179 error (duplicate comdat) when the compiler
+ // generates different symbol names with a very long common prefix:
+ // the dummy "&& true" disambiguates between the symbols generated by this
+ // BOOST_TEST instantiation and the preceding one.
+ BOOST_TEST(traits::is_integer && true);
+#else
+ BOOST_TEST(traits::is_integer);
+#endif
+ BOOST_TEST(traits::is_integral == true);
+ BOOST_TEST(traits::const_min == (traits::min)());
+ BOOST_TEST(traits::const_max == (traits::max)());
+}
+
+int main(int, char*[])
+{
+ runtest("bool", bool());
+ runtest("char", char());
+ typedef signed char signed_char;
+ runtest("signed char", signed_char());
+ typedef unsigned char unsigned_char;
+ runtest("unsigned char", unsigned_char());
+ runtest("wchar_t", wchar_t());
+ runtest("short", short());
+ typedef unsigned short unsigned_short;
+ runtest("unsigned short", unsigned_short());
+ runtest("int", int());
+ typedef unsigned int unsigned_int;
+ runtest("unsigned int", unsigned_int());
+ runtest("long", long());
+ typedef unsigned long unsigned_long;
+ runtest("unsigned long", unsigned_long());
+#ifndef BOOST_NO_INTEGRAL_INT64_T
+ //
+ // MS/Borland compilers can't support 64-bit member constants
+ // BeOS doesn't have specialisations for long long in SGI's <limits> header.
+ runtest("int64_t (possibly long long)", boost::int64_t());
+ runtest("uint64_t (possibly unsigned long long)", boost::uint64_t());
+#else
+ std::cout << "Skipped int64_t and uint64_t" << std::endl;
+#endif
+ // Some compilers don't pay attention to std:3.6.1/5 and issue a
+ // warning here if "return 0;" is omitted.
+ return boost::report_errors();
+}
+
diff --git a/test/static_log2_include_test.cpp b/test/static_log2_include_test.cpp
new file mode 100644
index 0000000..d39b871
--- /dev/null
+++ b/test/static_log2_include_test.cpp
@@ -0,0 +1,14 @@
+// Copyright John Maddock 2009.
+// Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/integer/static_log2.hpp> // must be the only #include!
+
+int main()
+{
+ boost::static_log2_argument_type arg = 0;
+ (void)arg;
+ boost::static_log2_result_type result = boost::static_log2<30>::value;
+ (void)result;
+}
diff --git a/test/static_log2_test.cpp b/test/static_log2_test.cpp
new file mode 100644
index 0000000..f92d801
--- /dev/null
+++ b/test/static_log2_test.cpp
@@ -0,0 +1,149 @@
+// Boost static_log2.hpp test program --------------------------------------//
+
+// (C) Copyright Daryle Walker 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 for most recent version including documentation.
+
+// Revision History
+// 01 Oct 2001 Initial version (Daryle Walker)
+
+#include <boost/detail/lightweight_test.hpp> // for main
+
+#include <boost/cstdlib.hpp> // for boost::exit_success
+#include <boost/integer/static_log2.hpp> // for boost::static_log2
+
+#include <iostream> // for std::cout (std::endl indirectly)
+
+
+// Macros to compact code
+#define PRIVATE_LB_TEST( v, e ) BOOST_TEST( ::boost::static_log2<v>::value == e )
+
+#define PRIVATE_PRINT_LB( v ) ::std::cout << "boost::static_log2<" << (v) \
+ << "> = " << ::boost::static_log2< (v) >::value << '.' << ::std::endl
+
+// Control to check for a compile-time error
+#ifndef CONTROL_LB_0_TEST
+#define PRIVATE_LB_0_TEST
+#else
+#define PRIVATE_LB_0_TEST PRIVATE_PRINT_LB( 0 )
+#endif
+
+
+// Main testing function
+int
+main
+(
+ int , // "argc" is unused
+ char * [] // "argv" is unused
+)
+{
+ std::cout << "Doing tests on static_log2." << std::endl;
+
+ PRIVATE_LB_0_TEST;
+
+ PRIVATE_LB_TEST( 1, 0 );
+
+ PRIVATE_LB_TEST( 2, 1 );
+ PRIVATE_LB_TEST( 3, 1 );
+
+ PRIVATE_LB_TEST( 4, 2 );
+ PRIVATE_LB_TEST( 5, 2 );
+ PRIVATE_LB_TEST( 6, 2 );
+ PRIVATE_LB_TEST( 7, 2 );
+
+ PRIVATE_LB_TEST( 8, 3 );
+ PRIVATE_LB_TEST( 9, 3 );
+ PRIVATE_LB_TEST( 10, 3 );
+ PRIVATE_LB_TEST( 11, 3 );
+ PRIVATE_LB_TEST( 12, 3 );
+ PRIVATE_LB_TEST( 13, 3 );
+ PRIVATE_LB_TEST( 14, 3 );
+ PRIVATE_LB_TEST( 15, 3 );
+
+ PRIVATE_LB_TEST( 16, 4 );
+ PRIVATE_LB_TEST( 17, 4 );
+ PRIVATE_LB_TEST( 18, 4 );
+ PRIVATE_LB_TEST( 19, 4 );
+ PRIVATE_LB_TEST( 20, 4 );
+ PRIVATE_LB_TEST( 21, 4 );
+ PRIVATE_LB_TEST( 22, 4 );
+ PRIVATE_LB_TEST( 23, 4 );
+ PRIVATE_LB_TEST( 24, 4 );
+ PRIVATE_LB_TEST( 25, 4 );
+ PRIVATE_LB_TEST( 26, 4 );
+ PRIVATE_LB_TEST( 27, 4 );
+ PRIVATE_LB_TEST( 28, 4 );
+ PRIVATE_LB_TEST( 29, 4 );
+ PRIVATE_LB_TEST( 30, 4 );
+ PRIVATE_LB_TEST( 31, 4 );
+
+ PRIVATE_LB_TEST( 32, 5 );
+ PRIVATE_LB_TEST( 33, 5 );
+ PRIVATE_LB_TEST( 34, 5 );
+ PRIVATE_LB_TEST( 35, 5 );
+ PRIVATE_LB_TEST( 36, 5 );
+ PRIVATE_LB_TEST( 37, 5 );
+ PRIVATE_LB_TEST( 38, 5 );
+ PRIVATE_LB_TEST( 39, 5 );
+ PRIVATE_LB_TEST( 40, 5 );
+
+ PRIVATE_LB_TEST( 63, 5 );
+
+ PRIVATE_LB_TEST( 64, 6 );
+ PRIVATE_LB_TEST( 65, 6 );
+
+ PRIVATE_LB_TEST( 127, 6 );
+
+ PRIVATE_LB_TEST( 128, 7 );
+ PRIVATE_LB_TEST( 129, 7 );
+
+ PRIVATE_LB_TEST( 255, 7 );
+
+ PRIVATE_LB_TEST( 256, 8 );
+ PRIVATE_LB_TEST( 257, 8 );
+
+ PRIVATE_LB_TEST( 511, 8 );
+
+ PRIVATE_LB_TEST( 512, 9 );
+ PRIVATE_LB_TEST( 513, 9 );
+
+ PRIVATE_LB_TEST( 1023, 9 );
+
+ PRIVATE_LB_TEST( 1024, 10 );
+ PRIVATE_LB_TEST( 1025, 10 );
+
+ PRIVATE_LB_TEST( 2047, 10 );
+
+ PRIVATE_LB_TEST( 2048, 11 );
+ PRIVATE_LB_TEST( 2049, 11 );
+
+ PRIVATE_LB_TEST( 4095, 11 );
+
+ PRIVATE_LB_TEST( 4096, 12 );
+ PRIVATE_LB_TEST( 4097, 12 );
+
+ PRIVATE_LB_TEST( 8191, 12 );
+
+ PRIVATE_LB_TEST( 8192, 13 );
+ PRIVATE_LB_TEST( 8193, 13 );
+
+ PRIVATE_LB_TEST( 16383, 13 );
+
+ PRIVATE_LB_TEST( 16384, 14 );
+ PRIVATE_LB_TEST( 16385, 14 );
+
+ PRIVATE_LB_TEST( 32767, 14 );
+
+ PRIVATE_LB_TEST( 32768, 15 );
+ PRIVATE_LB_TEST( 32769, 15 );
+
+ PRIVATE_LB_TEST( 65535, 15 );
+
+ PRIVATE_LB_TEST( 65536, 16 );
+ PRIVATE_LB_TEST( 65537, 16 );
+
+ return boost::report_errors();
+}
diff --git a/test/static_min_max_include_test.cpp b/test/static_min_max_include_test.cpp
new file mode 100644
index 0000000..8055062
--- /dev/null
+++ b/test/static_min_max_include_test.cpp
@@ -0,0 +1,14 @@
+// Copyright John Maddock 2009.
+// Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/integer/static_min_max.hpp> // must be the only #include!
+
+int main()
+{
+ boost::static_min_max_signed_type m = boost::static_signed_min<2, 3>::value + boost::static_signed_max<2, 3>::value;
+ (void)m;
+ boost::static_min_max_unsigned_type u = boost::static_unsigned_min<2, 3>::value + boost::static_unsigned_max<2, 3>::value;
+ (void)u;
+}
diff --git a/test/static_min_max_test.cpp b/test/static_min_max_test.cpp
new file mode 100644
index 0000000..124e137
--- /dev/null
+++ b/test/static_min_max_test.cpp
@@ -0,0 +1,92 @@
+// Boost static_min_max.hpp test program -----------------------------------//
+
+// (C) Copyright Daryle Walker 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 for most recent version including documentation.
+
+// Revision History
+// 23 Sep 2001 Initial version (Daryle Walker)
+
+#include <boost/detail/lightweight_test.hpp> // for main, BOOST_TEST
+
+#include <boost/cstdlib.hpp> // for boost::exit_success
+#include <boost/integer/static_min_max.hpp> // for boost::static_signed_min, etc.
+
+#include <iostream> // for std::cout (std::endl indirectly)
+
+
+// Main testing function
+int
+main
+(
+ int , // "argc" is unused
+ char * [] // "argv" is unused
+)
+{
+ using std::cout;
+ using std::endl;
+ using boost::static_signed_min;
+ using boost::static_signed_max;
+ using boost::static_unsigned_min;
+ using boost::static_unsigned_max;
+
+ // Two positives
+ cout << "Doing tests with two positive values." << endl;
+
+ BOOST_TEST( (static_signed_min< 9, 14>::value) == 9 );
+ BOOST_TEST( (static_signed_max< 9, 14>::value) == 14 );
+ BOOST_TEST( (static_signed_min<14, 9>::value) == 9 );
+ BOOST_TEST( (static_signed_max<14, 9>::value) == 14 );
+
+ BOOST_TEST( (static_unsigned_min< 9, 14>::value) == 9 );
+ BOOST_TEST( (static_unsigned_max< 9, 14>::value) == 14 );
+ BOOST_TEST( (static_unsigned_min<14, 9>::value) == 9 );
+ BOOST_TEST( (static_unsigned_max<14, 9>::value) == 14 );
+
+ // Two negatives
+ cout << "Doing tests with two negative values." << endl;
+
+ BOOST_TEST( (static_signed_min< -8, -101>::value) == -101 );
+ BOOST_TEST( (static_signed_max< -8, -101>::value) == -8 );
+ BOOST_TEST( (static_signed_min<-101, -8>::value) == -101 );
+ BOOST_TEST( (static_signed_max<-101, -8>::value) == -8 );
+
+ // With zero
+ cout << "Doing tests with zero and a positive or negative value." << endl;
+
+ BOOST_TEST( (static_signed_min< 0, 14>::value) == 0 );
+ BOOST_TEST( (static_signed_max< 0, 14>::value) == 14 );
+ BOOST_TEST( (static_signed_min<14, 0>::value) == 0 );
+ BOOST_TEST( (static_signed_max<14, 0>::value) == 14 );
+
+ BOOST_TEST( (static_unsigned_min< 0, 14>::value) == 0 );
+ BOOST_TEST( (static_unsigned_max< 0, 14>::value) == 14 );
+ BOOST_TEST( (static_unsigned_min<14, 0>::value) == 0 );
+ BOOST_TEST( (static_unsigned_max<14, 0>::value) == 14 );
+
+ BOOST_TEST( (static_signed_min< 0, -101>::value) == -101 );
+ BOOST_TEST( (static_signed_max< 0, -101>::value) == 0 );
+ BOOST_TEST( (static_signed_min<-101, 0>::value) == -101 );
+ BOOST_TEST( (static_signed_max<-101, 0>::value) == 0 );
+
+ // With identical
+ cout << "Doing tests with two identical values." << endl;
+
+ BOOST_TEST( (static_signed_min<0, 0>::value) == 0 );
+ BOOST_TEST( (static_signed_max<0, 0>::value) == 0 );
+ BOOST_TEST( (static_unsigned_min<0, 0>::value) == 0 );
+ BOOST_TEST( (static_unsigned_max<0, 0>::value) == 0 );
+
+ BOOST_TEST( (static_signed_min<14, 14>::value) == 14 );
+ BOOST_TEST( (static_signed_max<14, 14>::value) == 14 );
+ BOOST_TEST( (static_unsigned_min<14, 14>::value) == 14 );
+ BOOST_TEST( (static_unsigned_max<14, 14>::value) == 14 );
+
+ BOOST_TEST( (static_signed_min< -101, -101>::value) == -101 );
+ BOOST_TEST( (static_signed_max< -101, -101>::value) == -101 );
+
+ return boost::report_errors();
+}