Compare commits

..

3 Commits

75 changed files with 6273 additions and 2938 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,619 +0,0 @@
# Copyright 2021-2025 Andrey Semashev
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
concurrency:
group: ${{format('{0}:{1}', github.repository, github.ref)}}
cancel-in-progress: true
env:
GIT_FETCH_JOBS: 8
NET_RETRY_COUNT: 5
DEFAULT_BUILD_VARIANT: debug,release
jobs:
posix:
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
# Linux, gcc
- toolset: gcc-4.6
cxxstd: "0x"
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.6
sources:
- "ppa:ubuntu-toolchain-r/test"
- toolset: gcc-4.7
cxxstd: "11"
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.7
- toolset: gcc-4.8
cxxstd: "11"
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-4.8
- toolset: gcc-4.9
cxxstd: "11"
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.9
- toolset: gcc-5
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-5
- toolset: gcc-6
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-6
- toolset: gcc-7
cxxstd: "11,14,17"
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-7
- toolset: gcc-8
cxxstd: "11,14,17,2a"
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-8
- toolset: gcc-9
cxxstd: "11,14,17,2a"
os: ubuntu-latest
container: ubuntu:20.04
install:
- g++-9
- toolset: gcc-10
cxxstd: "11,14,17,20"
os: ubuntu-latest
container: ubuntu:20.04
install:
- g++-10
- toolset: gcc-11
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,23-gnu"
os: ubuntu-22.04
install:
- g++-11
- toolset: gcc-12
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,23-gnu"
os: ubuntu-22.04
install:
- g++-12
- toolset: gcc-13
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,23-gnu"
os: ubuntu-24.04
install:
- g++-13
- toolset: gcc-14
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,23-gnu,26-gnu"
os: ubuntu-24.04
install:
- g++-14
- toolset: gcc-15
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,23-gnu,26-gnu"
os: ubuntu-latest
container: ubuntu:25.04
install:
- g++-15
- name: UBSAN
toolset: gcc-13
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,23-gnu"
ubsan: 1
build_variant: debug
os: ubuntu-24.04
install:
- g++-13
# Linux, clang
- toolset: clang
compiler: clang++-3.5
cxxstd: "11"
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.5
- toolset: clang
compiler: clang++-3.6
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.6
- toolset: clang
compiler: clang++-3.7
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.7
- toolset: clang
compiler: clang++-3.8
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.8
- toolset: clang
compiler: clang++-3.9
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "11,14,17"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "11,14,17"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-7
# Note: clang-8 does not fully support C++20, so it is not compatible with libstdc++-8 in this mode
- toolset: clang
compiler: clang++-8
cxxstd: "11,14,17,2a"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-8
- g++-7
gcc_toolchain: 7
- toolset: clang
compiler: clang++-9
cxxstd: "11,14,17,2a"
os: ubuntu-latest
container: ubuntu:20.04
install:
- clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "11,14,17,20"
os: ubuntu-latest
container: ubuntu:20.04
install:
- clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "11,14,17,20"
os: ubuntu-22.04
install:
- clang-11
- toolset: clang
compiler: clang++-12
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,2b-gnu"
os: ubuntu-22.04
install:
- clang-12
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-13
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,2b-gnu"
os: ubuntu-22.04
install:
- clang-13
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-14
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,2b-gnu"
os: ubuntu-22.04
install:
- clang-14
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-15
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,2b-gnu"
os: ubuntu-22.04
install:
- clang-15
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-16
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,2b-gnu"
os: ubuntu-24.04
install:
- clang-16
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-17
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,23-gnu"
os: ubuntu-24.04
install:
- clang-17
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-18
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,23-gnu,26-gnu"
os: ubuntu-24.04
install:
- clang-18
- g++-13
- toolset: clang
compiler: clang++-19
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,23-gnu,26-gnu"
os: ubuntu-24.04
install:
- clang-19
- toolset: clang
compiler: clang++-20
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,23-gnu,26-gnu"
os: ubuntu-latest
container: ubuntu:25.04
install:
- clang-20
- toolset: clang
compiler: clang++-20
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,23-gnu,26-gnu"
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
os: ubuntu-latest
container: ubuntu:25.04
install:
- clang-20
- libc++-20-dev
- libc++abi-20-dev
- name: UBSAN
toolset: clang
compiler: clang++-18
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,23-gnu,26-gnu"
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
ubsan: 1
build_variant: debug
os: ubuntu-24.04
install:
- clang-18
- libc++-18-dev
- libc++abi-18-dev
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-13
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-14
timeout-minutes: 15
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
steps:
- name: Setup environment
run: |
if [ -f "/etc/debian_version" ]
then
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
export DEBIAN_FRONTEND=noninteractive
fi
if [ -n "${{matrix.container}}" ]
then
echo "GHA_CONTAINER=${{matrix.container}}" >> $GITHUB_ENV
if [ -f "/etc/debian_version" ]
then
# Use Azure APT mirrors in containers to avoid HTTP errors due to DDoS filters triggered by lots of CI jobs launching concurrently.
# Note that not all Ubuntu versions support "mirror+file:..." URIs in APT sources, so just use Azure mirrors exclusively.
# Note also that on recent Ubuntu versions DEB822 format is used for source files.
APT_SOURCES=()
if [ -d "/etc/apt/sources.list.d" ]
then
readarray -t APT_SOURCES < <(find "/etc/apt/sources.list.d" -type f -name '*.sources' -print)
fi
if [ -f "/etc/apt/sources.list" ]
then
APT_SOURCES+=("/etc/apt/sources.list")
fi
if [ "${#APT_SOURCES[@]}" -gt 0 ]
then
sed -i -E -e 's!([^ ]+) (http|https)://(archive|security)\.ubuntu\.com/ubuntu[^ ]*(.*)!\1 http://azure.archive.ubuntu.com/ubuntu/\4!' "${APT_SOURCES[@]}"
fi
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
if [ "$(apt-cache search "^python-is-python3$" | wc -l)" -ne 0 ]
then
PYTHON_PACKAGE="python-is-python3"
else
PYTHON_PACKAGE="python"
fi
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https ca-certificates make build-essential g++ $PYTHON_PACKAGE python3 perl git cmake
fi
fi
git config --global pack.threads 0
- name: Install packages
if: matrix.install
run: |
declare -a SOURCE_KEYS SOURCES
if [ -n "${{join(matrix.source_keys, ' ')}}" ]
then
SOURCE_KEYS=("${{join(matrix.source_keys, '" "')}}")
fi
if [ -n "${{join(matrix.sources, ' ')}}" ]
then
SOURCES=("${{join(matrix.sources, '" "')}}")
fi
for key in "${SOURCE_KEYS[@]}"
do
for i in {1..$NET_RETRY_COUNT}
do
echo "Adding key: $key"
wget -O - "$key" | sudo apt-key add - && break || sleep 2
done
done
if [ ${#SOURCES[@]} -gt 0 ]
then
APT_ADD_REPO_COMMON_ARGS=("-y")
APT_ADD_REPO_SUPPORTED_ARGS="$(apt-add-repository --help | perl -ne 'if (/^\s*-n/) { print "n"; } elsif (/^\s*-P/) { print "P"; } elsif (/^\s*-S/) { print "S"; } elsif (/^\s*-U/) { print "U"; }')"
if [ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*n*}" ]
then
APT_ADD_REPO_COMMON_ARGS+=("-n")
fi
APT_ADD_REPO_HAS_SOURCE_ARGS="$([ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*P*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*S*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*U*}" ] && echo 1 || echo 0)"
for source in "${SOURCES[@]}"
do
for i in {1..$NET_RETRY_COUNT}
do
APT_ADD_REPO_ARGS=("${APT_ADD_REPO_COMMON_ARGS[@]}")
if [ $APT_ADD_REPO_HAS_SOURCE_ARGS -ne 0 ]
then
case "$source" in
"ppa:"*)
APT_ADD_REPO_ARGS+=("-P")
;;
"deb "*)
APT_ADD_REPO_ARGS+=("-S")
;;
*)
APT_ADD_REPO_ARGS+=("-U")
;;
esac
fi
APT_ADD_REPO_ARGS+=("$source")
echo "apt-add-repository ${APT_ADD_REPO_ARGS[@]}"
sudo -E apt-add-repository "${APT_ADD_REPO_ARGS[@]}" && break || sleep 2
done
done
fi
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y ${{join(matrix.install, ' ')}}
- name: Setup GCC Toolchain
if: matrix.gcc_toolchain
run: |
GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain"
echo "GCC_TOOLCHAIN_ROOT=\"$GCC_TOOLCHAIN_ROOT\"" >> $GITHUB_ENV
MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
mkdir -p "$GCC_TOOLCHAIN_ROOT"
ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include"
ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin"
mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET"
ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}"
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
DEPINST_ARGS=()
GIT_VERSION="$(git --version | sed -e 's/git version //')"
GIT_HAS_JOBS=1
if [ -f "/etc/debian_version" ]
then
if $(dpkg --compare-versions "$GIT_VERSION" lt 2.8.0)
then
GIT_HAS_JOBS=0
fi
else
declare -a GIT_VER=(${GIT_VERSION//./ })
declare -a GIT_MIN_VER=(2 8 0)
for ((i=0; i<${#GIT_VER[@]}; i++))
do
if [ -z "${GIT_MIN_VER[i]}" ]
then
GIT_MIN_VER[i]=0
fi
if [ "${GIT_VER[i]}" -lt "${GIT_MIN_VER[i]}" ]
then
GIT_HAS_JOBS=0
break
fi
done
fi
if [ "$GIT_HAS_JOBS" -ne 0 ]
then
DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS")
fi
mkdir -p snapshot
cd snapshot
echo "Downloading library snapshot: https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
curl -L --retry "$NET_RETRY_COUNT" -o "${LIBRARY}-${GITHUB_SHA}.tar.gz" "https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
tar -xf "${LIBRARY}-${GITHUB_SHA}.tar.gz"
if [ ! -d "${LIBRARY}-${GITHUB_SHA}" ]
then
echo "Library snapshot does not contain the library directory ${LIBRARY}-${GITHUB_SHA}:"
ls -la
exit 1
fi
rm -f "${LIBRARY}-${GITHUB_SHA}.tar.gz"
cd ..
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" "boost-root"
cd boost-root
mkdir -p libs
rm -rf "libs/$LIBRARY"
mv -f "../snapshot/${LIBRARY}-${GITHUB_SHA}" "libs/$LIBRARY"
rm -rf "../snapshot"
git submodule update --init tools/boostdep
DEPINST_ARGS+=("$LIBRARY")
python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}"
if [ -z "${{matrix.cmake_tests}}" ]
then
./bootstrap.sh
./b2 headers
if [ -n "${{matrix.compiler}}" -o -n "$GCC_TOOLCHAIN_ROOT" ]
then
echo -n "using ${{matrix.toolset}} : : ${{matrix.compiler}}" > ~/user-config.jam
if [ -n "$GCC_TOOLCHAIN_ROOT" ]
then
echo -n " : <compileflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\" <linkflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\"" >> ~/user-config.jam
fi
echo " ;" >> ~/user-config.jam
fi
fi
- name: Run tests
if: matrix.cmake_tests == ''
run: |
cd boost-root
B2_ARGS=("-j" "$BUILD_JOBS" "toolset=${{matrix.toolset}}" "cxxstd=${{matrix.cxxstd}}")
if [ -n "${{matrix.build_variant}}" ]
then
B2_ARGS+=("variant=${{matrix.build_variant}}")
else
B2_ARGS+=("variant=$DEFAULT_BUILD_VARIANT")
fi
if [ -n "${{matrix.threading}}" ]
then
B2_ARGS+=("threading=${{matrix.threading}}")
fi
if [ -n "${{matrix.ubsan}}" ]
then
export UBSAN_OPTIONS="print_stacktrace=1"
B2_ARGS+=("cxxflags=-fsanitize=undefined -fno-sanitize-recover=undefined" "linkflags=-fsanitize=undefined -fuse-ld=gold" "define=UBSAN=1" "debug-symbols=on" "visibility=global")
fi
if [ -n "${{matrix.cxxflags}}" ]
then
B2_ARGS+=("cxxflags=${{matrix.cxxflags}}")
fi
if [ -n "${{matrix.linkflags}}" ]
then
B2_ARGS+=("linkflags=${{matrix.linkflags}}")
fi
B2_ARGS+=("libs/$LIBRARY/test")
./b2 "${B2_ARGS[@]}"
windows:
strategy:
fail-fast: false
matrix:
include:
- toolset: msvc-14.3
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
- toolset: clang-win
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2022
- toolset: gcc
cxxstd: "11,14,17,20,23"
addrmd: 64
os: windows-2022
timeout-minutes: 15
runs-on: ${{matrix.os}}
steps:
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
mkdir snapshot
cd snapshot
echo Downloading library snapshot: https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip
curl -L --retry %NET_RETRY_COUNT% -o "%LIBRARY%-%GITHUB_SHA%.zip" "https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip"
tar -xf "%LIBRARY%-%GITHUB_SHA%.zip"
if not exist "%LIBRARY%-%GITHUB_SHA%\" (
echo Library snapshot does not contain the library directory %LIBRARY%-%GITHUB_SHA%:
dir
exit /b 1
)
del /f "%LIBRARY%-%GITHUB_SHA%.zip"
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
if not exist "libs\" mkdir libs
if exist "libs\%LIBRARY%\" rmdir /s /q "libs\%LIBRARY%"
move /Y "..\snapshot\%LIBRARY%-%GITHUB_SHA%" "libs\%LIBRARY%"
rmdir /s /q "..\snapshot"
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
- name: Run tests
shell: cmd
run: |
cd boost-root
if not "${{matrix.cxxstd}}" == "" set CXXSTD=cxxstd=${{matrix.cxxstd}}
if not "${{matrix.addrmd}}" == "" set ADDRMD=address-model=${{matrix.addrmd}}
if not "${{matrix.build_variant}}" == "" (set BUILD_VARIANT=variant=${{matrix.build_variant}}) else (set BUILD_VARIANT=variant=%DEFAULT_BUILD_VARIANT%)
b2 -j %NUMBER_OF_PROCESSORS% libs/%LIBRARY%/test toolset=${{matrix.toolset}} %CXXSTD% %ADDRMD% %BUILD_VARIANT% embed-manifest-via=linker

View File

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

View File

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

View File

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

View File

@ -1,28 +0,0 @@
# Copyright René Ferdinand Rivera Morell 2023-2024
# 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)
require-b2 5.2 ;
constant boost_dependencies :
/boost/assert//boost_assert
/boost/config//boost_config
/boost/core//boost_core
/boost/static_assert//boost_static_assert
/boost/throw_exception//boost_throw_exception
/boost/type_traits//boost_type_traits ;
project /boost/integer
: common-requirements
<include>include
;
explicit
[ alias boost_integer : : : : <library>$(boost_dependencies) ]
[ alias all : boost_integer test ]
;
call-if : boost-library integer
;

View File

@ -1,12 +1,88 @@
# jamfile to build Boost.Integer Documentation.
# Copyright John Maddock 2005. Use, modification, and distribution are
# subject to the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# Revised to include Doxygen and Autoindex, and code snippets from examples.
# Copyright Paul A. Bristow 2015
using boostbook ;
using doxygen ; # Required if you want to use Doxygen.
using quickbook ;
using auto-index ;
path-constant here : . ; # convenient to refer to files in the same directory as this jamfile.v2
path-constant parent : .. ; # Parent directory, /libs/integer/
if --enable-index in [ modules.peek : ARGV ]
{
ECHO "Building the Integer docs with automatic index generation enabled." ;
using auto-index ;
project integer_doc : requirements
<auto-index>on
<auto-index-script>integer.idx
<auto-index-prefix>.
<auto-index-verbose>on
<format>html:<auto-index-internal>on
<format>html:<xsl:param>generate.index=0
<format>pdf:<auto-index-internal>on
<format>pdf:<xsl:param>index.on.type=1
<quickbook-define>enable_index ;
}
else
{
project integer_doc ;
ECHO "Building the Integer docs with automatic index generation disabled. Try building with --enable-index." ;
}
xml integer
:
integer.qbk # This is 'root' Quickbook file (that may include other .qbk files).
;
doxygen autodoc
:
[ glob $(here)/../include/boost/*.hpp ]
[ glob $(here)/../include/boost/integer/*.hpp ]
# but could also include this and switch Boost.Integer C++ reference info to include implementation details (or not) using Doxygen macro DETAIL.
# See http://www.stack.nl/~dimitri/doxygen/manual/commands.html#cmdcond
# and http://www.stack.nl/~dimitri/doxygen/manual/config.html#cfg_enabled_sections
# by adding this line below with other Doxygen parameters
# <doxygen:param>ENABLED_SECTIONS="DETAIL"
# Or setting this macro value ENABLED_SECTIONS="DETAIL" in /doxygen/integer_doxyfile.txt for Standalone Doxygen documentaation.
# This might be useful for maintainers.
:
<doxygen:param>PROJECT_NAME="Integer"
<doxygen:param>RECURSIVE=NO # Specify all folders and files above explicitly.
<doxygen:param>ENABLE_PREPROCESSING=YES
<doxygen:param>EXPAND_ONLY_PREDEF=YES
<doxygen:param>EXTRACT_ALL=NO
<doxygen:param>EXTRACT_PRIVATE=NO
<doxygen:param>HIDE_UNDOC_MEMBERS=YES
<doxygen:param>MACRO_EXPANSION=YES
<doxygen:param>SORT_MEMBER_DOCS=NO
<doxygen:param>SHOW_INCLUDE_FILES=NO
<doxygen:param>MAX_INITIALIZER_LINES=0
<doxygen:param>VERBATIM_HEADERS=NO
<doxygen:param>WARNINGS=NO # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings for undocumented members.
# If EXTRACT_ALL is set to YES then this flag will automatically be disabled.
<doxygen:param>WARN_IF_UNDOCUMENTED=YES # If WARN_IF_UNDOCUMENTED is set to YES,
# then doxygen will generate warnings for all undocumented members.
<doxygen:param>WARN_IF_DOC_ERROR=YES # If WARN_IF_DOC_ERROR is set to YES, Doxygen will generate warnings for
# potential errors in the documentation.
<doxygen:param>WARN_LOGFILE=AutoDoxywarnings.log # This may not be empty (usually not a good sign!), depending on options chosen.
# Much better to send message to a logfile than the default stderr.
# and make sure that there are no Doxygen errors or significant warnings in the log file.
#<reftitle>"Reference" # Default is "Reference" but helpful to specify library.
<xsl:param>"boost.doxygen.reftitle=Boost.Integer C++ Reference"
# See Doxygen configuration for detailed explanation of these options.
# Usually these match those in /doc/doxygen/integer_doxyfile.txt.
;
xml integer : integer.qbk ;
boostbook standalone
:
integer
@ -14,6 +90,7 @@ boostbook standalone
# HTML options first:
# Use graphics not text for navigation:
<xsl:param>navig.graphics=1
<xsl:param>chapter.autolabel=0 # No Chapter numbering.
# 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:
@ -25,7 +102,7 @@ boostbook standalone
# How far down we go with TOC's
<xsl:param>generate.section.toc.level=4
# Path for links to Boost:
<xsl:param>"boost.root=../../../.."
<xsl:param>boost.root=../../../..
# PDF Options:
# TOC Generation: this is needed for FOP-0.9 and later:
@ -46,15 +123,21 @@ boostbook standalone
# default pnd graphics are awful in PDF form,
# better use SVG's instead:
<format>pdf:<xsl:param>admon.graphics.extension=".svg"
<format>pdf:<xsl:param>"admon.graphics.path=$(boost-images)/"
<format>pdf:<xsl:param>"boost.url.prefix=https://www.boost.org/doc/libs/release/libs/integer/doc/html"
<format>pdf:<xsl:param>admon.graphics.path=$(boost-images)/
# Use Arial for PDF.
<format>pdf:<xsl:param>title.font.family="sans-serif"
<format>pdf:<xsl:param>body.font.family="sans-serif"
<format>pdf:<xsl:param>monospace.font.family="sans-serif"
<dependency>autodoc # Add Doxygen info.
;
install pdfinstall : standalone/<format>pdf : <location>. <install-type>PDF ;
# install pdfinstall : standalone/<format>pdf : <location>. <install-type>PDF <name>boost.pdf ;
install pdf-install : standalone : <install-type>PDF <location>. <name>integer.pdf ;
explicit pdfinstall ;
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : standalone ;
explicit boostrelease ;

View File

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
[section:gcd_lcm Greatest Common Divisor and Least Common Multiple]
[mathpart gcd_lcm Integer Utilities (Greatest Common Divisor and Least Common Multiple)]
[section Introduction]
@ -15,7 +15,7 @@ programming problems.
namespace boost
{
namespace integer
namespace math
{
template < typename IntegerType >
@ -24,20 +24,9 @@ programming problems.
class lcm_evaluator;
template < typename IntegerType >
constexpr IntegerType gcd( IntegerType const &a, IntegerType const &b );
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);
IntegerType lcm( IntegerType const &a, IntegerType const &b );
typedef ``['see-below]`` static_gcd_type;
@ -53,10 +42,10 @@ programming problems.
[section GCD Function Object]
[*Header: ] [@../../../../boost/integer/common_factor_rt.hpp <boost/integer/common_factor_rt.hpp>]
[*Header: ] [@../../../../boost/math/common_factor_rt.hpp <boost/math/common_factor_rt.hpp>]
template < typename IntegerType >
class boost::integer::gcd_evaluator
class boost::math::gcd_evaluator
{
public:
// Types
@ -65,12 +54,11 @@ programming problems.
typedef IntegerType second_argument_type;
// Function object interface
constexpr result_type operator ()(
first_argument_type const &a,
result_type operator ()( first_argument_type const &a,
second_argument_type const &b ) const;
};
The boost::integer::gcd_evaluator class template defines a function object
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.
@ -82,17 +70,14 @@ the GCD function template. If a numeric type wants to customize evaluations
of its greatest common divisors, then the type should specialize on the
gcd_evaluator class template.
Note that these function objects are `constexpr` in C++14 and later only.
They are also declared `noexcept` when appropriate.
[endsect]
[section LCM Function Object]
[*Header: ] [@../../../../boost/integer/common_factor_rt.hpp <boost/integer/common_factor_rt.hpp>]
[*Header: ] [@../../../../boost/math/common_factor_rt.hpp <boost/math/common_factor_rt.hpp>]
template < typename IntegerType >
class boost::integer::lcm_evaluator
class boost::math::lcm_evaluator
{
public:
// Types
@ -101,12 +86,11 @@ They are also declared `noexcept` when appropriate.
typedef IntegerType second_argument_type;
// Function object interface
constexpr result_type operator ()(
first_argument_type const &a,
result_type operator ()( first_argument_type const &a,
second_argument_type const &b ) const;
};
The boost::integer::lcm_evaluator class template defines a function object
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
@ -119,69 +103,42 @@ of the LCM function template. If a numeric type wants to customize
evaluations of its least common multiples, then the type should
specialize on the lcm_evaluator class template.
Note that these function objects are constexpr in C++14 and later only.
They are also declared `noexcept` when appropriate.
[endsect]
[section:run_time Run-time GCD & LCM Determination]
[*Header: ] [@../../../../boost/integer/common_factor_rt.hpp <boost/integer/common_factor_rt.hpp>]
[*Header: ] [@../../../../boost/math/common_factor_rt.hpp <boost/math/common_factor_rt.hpp>]
template < typename IntegerType >
constexpr IntegerType boost::integer::gcd( IntegerType const &a, IntegerType const &b );
IntegerType boost::math::gcd( IntegerType const &a, IntegerType const &b );
template < typename IntegerType >
constexpr IntegerType boost::integer::lcm( IntegerType const &a, IntegerType const &b );
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::integer::gcd function template returns the greatest common
The boost::math::gcd function template returns the greatest common
(nonnegative) divisor of the two integers passed to it.
`boost::integer::gcd_range` is the iteration of the above gcd algorithm over a
range, returning the greatest common divisor of all the elements. The algorithm
terminates when the gcd reaches unity or the end of the range. Thus it also
returns the iterator after the last element inspected because this may not be
equal to the end of the range. The variadic version of `gcd` behaves similarly
but does not indicate which input value caused the gcd to reach unity.
The boost::integer::lcm function template returns the least common
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.
The function templates are parameterized on the function arguments'
IntegerType, which is also the return type. Internally, these function
templates use an object of the corresponding version of the
gcd_evaluator and lcm_evaluator class templates, respectively.
[endsect]
[section:compile_time Compile time GCD and LCM determination]
[note These functions are deprecated in favor of constexpr `gcd` and `lcm` on C++14 capable compilers.]
[*Header: ] [@../../../../boost/integer/common_factor_ct.hpp <boost/integer/common_factor_ct.hpp>]
[*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::integer::static_gcd : public mpl::integral_c<static_gcd_type, implementation_defined>
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::integer::static_lcm : public mpl::integral_c<static_gcd_type, implementation_defined>
struct boost::math::static_lcm : public mpl::integral_c<static_gcd_type, implementation_defined>
{
};
@ -190,7 +147,7 @@ for use in integral-constant-expressions by the compiler. Usually this
the same type as `boost::uintmax_t`, but may fall back to being `unsigned long`
for some older compilers.
The boost::integer::static_gcd and boost::integer::static_lcm class templates
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/
@ -201,7 +158,7 @@ is beyond the range of `static_gcd_type`.
[h3 Example]
#include <boost/integer/common_factor.hpp>
#include <boost/math/common_factor.hpp>
#include <algorithm>
#include <iterator>
#include <iostream>
@ -212,28 +169,28 @@ is beyond the range of `static_gcd_type`.
using std::endl;
cout << "The GCD and LCM of 6 and 15 are "
<< boost::integer::gcd(6, 15) << " and "
<< boost::integer::lcm(6, 15) << ", respectively."
<< boost::math::gcd(6, 15) << " and "
<< boost::math::lcm(6, 15) << ", respectively."
<< endl;
cout << "The GCD and LCM of 8 and 9 are "
<< boost::integer::static_gcd<8, 9>::value
<< boost::math::static_gcd<8, 9>::value
<< " and "
<< boost::integer::static_lcm<8, 9>::value
<< 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::integer::gcd_evaluator<int>() );
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/integer/common_factor.hpp>]
[section:gcd_header Header <boost/math/common_factor.hpp>]
This header simply includes the headers
[@../../../../boost/integer/common_factor_ct.hpp <boost/integer/common_factor_ct.hpp>]
and [@../../../../boost/integer/common_factor_rt.hpp <boost/integer/common_factor_rt.hpp>].
[@../../../../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
@ -243,7 +200,7 @@ were moved to separate headers (since they were independent of each other).
[section:demo Demonstration Program]
The program [@../../../../libs/integer/test/common_factor_test.cpp common_factor_test.cpp] is a demonstration of the results from
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
@ -256,14 +213,12 @@ the run-time function templates.)
The greatest common divisor and least common multiple functions are
greatly used in some numeric contexts, including some of the other
Boost libraries. Centralizing these functions to one header improves
code factoring and eases maintenance.
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.
@ -280,11 +235,13 @@ pool library. The code had updates by Helmut Zeisel.
[endsect]
[endsect]
[endmathpart]
[/
Copyright 2005, 2013 Daryle Walker.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
https://www.boost.org/LICENSE_1_0.txt).
http://www.boost.org/LICENSE_1_0.txt).
]

View File

@ -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.78.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 &#169; 2001-2009 Beman
Dawes, Daryle Walker, Gennaro Prota, John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</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>

View File

@ -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.78.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">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">cstdint</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code> into <a href="../../../../../libs/config/index.html" target="_top">Boost.Config</a>.
</li></ul></div>
<h5>
<a name="boost_integer.history.h1"></a>
<span class="phrase"><a name="boost_integer.history.1_42_0"></a></span><a class="link" href="history.html#boost_integer.history.1_42_0">1.42.0</a>
</h5>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
Reverted Trunk to release branch state (i.e. a "known good state").
</li>
<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 &#169; 2001-2009 Beman
Dawes, Daryle Walker, Gennaro Prota, John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</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>

View File

@ -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.78.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="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="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="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.integer"></a><a class="link" href="integer.html" title="Integer Type Selection">Integer Type Selection</a>
</h2></div></div></div>
<div class="toc"><dl class="toc">
<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">&lt;boost/integer.hpp&gt;</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">&lt;</span><span class="keyword">typename</span> <span class="identifier">LeastInt</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">int_fast_t</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="emphasis"><em>implementation-defined-type</em></span> <span class="identifier">type</span><span class="special">;</span>
<span class="special">};</span>
<span class="comment">// signed</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">int</span> <span class="identifier">Bits</span><span class="special">&gt;</span>
<span class="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">&lt;</span><span class="identifier">least</span><span class="special">&gt;::</span><span class="identifier">fast</span> <span class="identifier">fast</span><span class="special">;</span>
<span class="special">};</span>
<span class="comment">// unsigned</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">int</span> <span class="identifier">Bits</span><span class="special">&gt;</span>
<span class="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">&lt;</span><span class="identifier">least</span><span class="special">&gt;::</span><span class="identifier">fast</span> <span class="identifier">fast</span><span class="special">;</span>
<span class="special">};</span>
<span class="comment">// signed</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">MaxValue</span><span class="special">&gt;</span>
<span class="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">&lt;</span><span class="identifier">least</span><span class="special">&gt;::</span><span class="identifier">fast</span> <span class="identifier">fast</span><span class="special">;</span>
<span class="special">};</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">MinValue</span><span class="special">&gt;</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">&lt;</span><span class="identifier">least</span><span class="special">&gt;::</span><span class="identifier">fast</span> <span class="identifier">fast</span><span class="special">;</span>
<span class="special">};</span>
<span class="comment">// unsigned</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">Value</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">uint_value_t</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="emphasis"><em>implementation-defined-type</em></span> <span class="identifier">least</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">int_fast_t</span><span class="special">&lt;</span><span class="identifier">least</span><span class="special">&gt;::</span><span class="identifier">fast</span> <span class="identifier">fast</span><span class="special">;</span>
<span class="special">};</span>
<span class="special">}</span> <span class="comment">// namespace boost</span>
</pre>
</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&#160;1.&#160;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&lt;N&gt;::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&lt;N&gt;::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&lt;N&gt;::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&lt;N&gt;::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&lt;N&gt;::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&lt;N&gt;::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&lt;V&gt;::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&lt;V&gt;::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&lt;V&gt;::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&lt;V&gt;::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&lt;V&gt;::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&lt;V&gt;::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">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="comment">//...</span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">int_t</span><span class="special">&lt;</span><span class="number">24</span><span class="special">&gt;::</span><span class="identifier">least</span> <span class="identifier">my_var</span><span class="special">;</span> <span class="comment">// my_var has at least 24-bits</span>
<span class="comment">//...</span>
<span class="comment">// This one is guarenteed not to be truncated:</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">int_max_value_t</span><span class="special">&lt;</span><span class="number">1000</span><span class="special">&gt;::</span><span class="identifier">least</span> <span class="identifier">my1000</span> <span class="special">=</span> <span class="number">1000</span><span class="special">;</span>
<span class="comment">//...</span>
<span class="comment">// This one is guarenteed not to be truncated, and as fast</span>
<span class="comment">// to manipulate as possible, its size may be greater than</span>
<span class="comment">// that of my1000:</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">int_max_value_t</span><span class="special">&lt;</span><span class="number">1000</span><span class="special">&gt;::</span><span class="identifier">fast</span> <span class="identifier">my_fast1000</span> <span class="special">=</span> <span class="number">1000</span><span class="special">;</span>
<span class="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">&lt;boost/cstdint.hpp&gt;</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 &#169; 2001-2009 Beman
Dawes, Daryle Walker, Gennaro Prota, John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</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="mask.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@ -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.78.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 class="toc">
<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">&lt;boost/integer/static_log2.hpp&gt;</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">&lt;</span><span class="identifier">static_log2_argument_type</span> <span class="identifier">arg</span><span class="special">&gt;</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">&lt;</span> <span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">static_log2</span><span class="special">&lt;</span> <span class="number">0</span> <span class="special">&gt;</span>
<span class="special">{</span>
<span class="comment">// The logarithm of zero is undefined.</span>
<span class="special">};</span>
<span class="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 &#169; 2001-2009 Beman
Dawes, Daryle Walker, Gennaro Prota, John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</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>

View File

@ -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.78.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="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="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="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 class="toc">
<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">&lt;boost/integer/integer_mask.hpp&gt;</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">&lt;</span><span class="identifier">cstddef</span><span class="special">&gt;</span> <span class="comment">// for std::size_t</span>
<span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">Bit</span><span class="special">&gt;</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">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">Bits</span><span class="special">&gt;</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&#160;2.&#160;Members of the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">high_bit_mask_t</span></code>
Class Template</b></p>
<div class="table-contents"><table class="table" summary="Members of the boost::high_bit_mask_t
Class Template">
<colgroup>
<col>
<col>
</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&#160;3.&#160;Members of the <code class="literal">boost::low_bits_mask_t</code> Class Template</b></p>
<div class="table-contents"><table class="table" summary="Members of the boost::low_bits_mask_t Class Template">
<colgroup>
<col>
<col>
</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">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">/</span><span class="identifier">integer_mask</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="comment">//...</span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">high_bit_mask_t</span><span class="special">&lt;</span><span class="number">29</span><span class="special">&gt;</span> <span class="identifier">mask1_type</span><span class="special">;</span>
<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">&lt;</span><span class="number">15</span><span class="special">&gt;</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">&amp;=</span> <span class="identifier">mask2_type</span><span class="special">::</span><span class="identifier">sig_bits_fast</span><span class="special">;</span>
<span class="comment">//...</span>
<span class="special">}</span>
</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 &#169; 2001-2009 Beman
Dawes, Daryle Walker, Gennaro Prota, John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</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="log2.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@ -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.78.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 class="toc">
<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">&lt;boost/integer/static_min_max.hpp&gt;</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">&lt;</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">&gt;</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">&lt;</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">&gt;</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">&lt;</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">&gt;</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">&lt;</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">&gt;</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">&lt;</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">&gt;</span>
<span class="keyword">template</span> <span class="special">&lt;</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">&gt;</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">&lt;</span><span class="identifier">AddendSize1</span><span class="special">,</span> <span class="identifier">AddendSize2</span><span class="special">&gt;::</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">&amp;</span><span class="identifier">a1</span><span class="special">,</span> <span class="identifier">addend2_type</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="identifier">a2</span><span class="special">,</span> <span class="identifier">sum_type</span> <span class="special">&amp;</span><span class="identifier">s</span> <span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="special">};</span>
<span class="comment">//...</span>
<span class="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">&lt;</span><span class="number">3</span><span class="special">,</span><span class="number">2</span><span class="special">&gt;</span> <span class="identifier">obj</span><span class="special">;</span>
<span class="identifier">obj</span><span class="special">(</span> <span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">,</span> <span class="identifier">s</span> <span class="special">);</span> <span class="comment">// 's' should be 429 or { 9, 2, 4, 0 }</span>
<span class="comment">//...</span>
<span class="special">}</span>
</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 &#169; 2001-2009 Beman
Dawes, Daryle Walker, Gennaro Prota, John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</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>

View File

@ -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.78.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 class="toc">
<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 &lt;limits&gt; header supplies a class template
<code class="computeroutput"><span class="identifier">numeric_limits</span><span class="special">&lt;&gt;</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">&lt;&gt;</span></code> are:
</p>
<pre class="programlisting"><span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">is_specialized</span><span class="special">;</span> <span class="comment">// Will be true for integer types.</span>
<span class="keyword">static</span> <span class="identifier">T</span> <span class="identifier">min</span><span class="special">()</span> <span class="keyword">throw</span><span class="special">();</span> <span class="comment">// Smallest representable value.</span>
<span class="keyword">static</span> <span class="identifier">T</span> <span class="identifier">max</span><span class="special">()</span> <span class="keyword">throw</span><span class="special">();</span> <span class="comment">// Largest representable value.</span>
<span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">digits</span><span class="special">;</span> <span class="comment">// For integers, the number of value bits.</span>
<span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">digits10</span><span class="special">;</span> <span class="comment">// The number of base 10 digits that can be represented.</span>
<span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">is_signed</span><span class="special">;</span> <span class="comment">// True if the type is signed.</span>
<span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">is_integer</span><span class="special">;</span> <span class="comment">// Will be true for all integer types.</span>
</pre>
<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">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</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">&lt;</span><span class="identifier">T</span><span class="special">&gt;</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&lt;T&gt;::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&lt;T&gt;::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&lt;&gt;::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 &#169; 2001-2009 Beman
Dawes, Daryle Walker, Gennaro Prota, John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</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>

228
doc/html/index.html Normal file
View File

@ -0,0 +1,228 @@
<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.78.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 &#169; 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 class="toc">
<dt><span class="section"><a href="index.html#boost_integer.overview">Overview</a></span></dt>
<dt><span class="section"><a href="boost_integer/traits.html">Integer Traits</a></span></dt>
<dt><span class="section"><a href="boost_integer/integer.html">Integer Type Selection</a></span></dt>
<dt><span class="section"><a href="boost_integer/mask.html">Integer Masks</a></span></dt>
<dt><span class="section"><a href="boost_integer/log2.html">Compile Time log2 Calculation</a></span></dt>
<dt><span class="section"><a href="boost_integer/minmax.html">Compile time min/max calculation</a></span></dt>
<dt><span class="section"><a href="boost_integer/history.html">History</a></span></dt>
<dt><span class="section"><a href="boost_integer/cstdint.html">Removed from library: Standard Integer
Types</a></span></dt>
</dl>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_integer.overview"></a><a class="link" href="index.html#boost_integer.overview" title="Overview">Overview</a>
</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">&lt;boost/integer_fwd.hpp&gt;</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">&lt;boost/integer_traits.hpp&gt;</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">&lt;boost/integer.hpp&gt;</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/mask.html" title="Integer Masks">Integer Masks</a>.
</p>
</td>
<td>
<p>
<code class="literal"><a href="../../../../boost/integer/integer_mask.hpp" target="_top">&lt;boost/integer/integer_mask.hpp&gt;</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">&lt;boost/integer/static_log2.hpp&gt;</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">&lt;boost/integer/static_min_max.hpp&gt;</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: June 01, 2014 at 19:57:36 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>

28
doc/integer.idx Normal file
View File

@ -0,0 +1,28 @@
# integer.idx for Boost.integer/Spreadinteger Quickbook, Doxygen and Auto-index.
# Note needs more customization to be useful in practice! TODO?
#!debug "\<\w*\>"
# integer Header files.
!scan-path "../include/boost/" ".*\.hpp" false
!scan-path "../include/boost/integer" ".*\.hpp" false
# All example source files, assuming no sub-folders.
# integer example files.
#!scan-path "../example" ".*\.cpp" true
# Allow alternative spellings colour | color, and plurals etc.
color \<\w*(colour|color)\w*\>
example \<example\w*\>
font \<font\w*\>
greek
ioflags
origin
outlier
maximum \<max\w*\>
minimum \<min\w*\>
precision
range \<\w*\range\w*\>
title
Unicode \<unicode\w*\>

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -0,0 +1,62 @@
// boost integer_common_factor_example.cpp
// Copyright Paul A. Bristow 2015
// 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)
// Caution: this file contains Quickbook markup as well as code
// and comments, don't change any of the special comment markups!
// #include <boost/integer/common_factor.hpp> // Includes both ct and rt but now deprecated.
//[integer_common_factor_example_0]
#include <boost/integer/common_factor_ct.hpp> // For compile-time GCD & LCM Determination.
#include <boost/integer/common_factor_rt.hpp> // For run-time GCD & LCM Determination.
//] [/integer_common_factor_example_0]
#include <iostream>
#include <algorithm>
#include <iterator>
#include <limits> // for numeric_limits min and max.
int main()
{
//[integer_common_factor_example_1
std::cout << "The run-time GCD and LCM of 6 and 15 are "
<< boost::integer::gcd(6, 15) << " and "
<< boost::integer::lcm(6, 15) << ", respectively."
<< std::endl;
// The GCD and LCM of 6 and 15 are 3 and 30, respectively.
//] [/integer_common_factor_example_1]
//[integer_common_factor_example_2
std::cout << "The compile-time GCD and LCM of 8 and 9 are "
<< boost::integer::static_gcd<8, 9>::value
<< " and "
<< boost::integer::static_lcm<8, 9>::value
<< ", respectively." << std::endl;
// The GCD and LCM of 8 and 9 are 1 and 72, respectively.
//] [/integer_common_factor_example_2]
//[integer_common_factor_example_3
int a[] = { 4, 5, 6 }, b[] = { 7, 8, 9 }, c[3];
std::transform(a, a + 3, b, c, boost::integer::gcd_evaluator<int>());
std::copy(c, c + 3, std::ostream_iterator<int>(std::cout, " "));
//] [/integer_common_factor_example_3]
} // int main
/*
//[integer_common_factor_example_output_1
The run-time GCD and LCM of 6 and 15 are 3 and 30, respectively.
The compile-time GCD and LCM of 8 and 9 are 1 and 72, respectively.
//] [/integer_common_factor_example_output_1]
//[integer_common_factor_example_output_2
1 1 3
//] [/integer_common_factor_example_output_2]
*/

View File

@ -0,0 +1,41 @@
// boost integer_log2_example.cpp
// Copyright Paul A. Bristow 2015
// 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)
// Caution: this file contains Quickbook markup as well as code
// and comments, don't change any of the special comment markups!
//[integer_log2_example_0
#include <boost/integer/static_log2.hpp> // For boost::static_log2
//] [/integer_log2s_example_0]
#include <iostream>
#include <limits> // for numeric_limits min and max.
//[integer_log2_example_
//] [/integer_log2s_example_]
int main()
{
//[integer_log2_example_1
int n = boost::static_log2<256>::value;
//] [/integer_log2_example_1]
std::cout << n << std::endl; // 8
//[integer_log2_example_2
int n2 = boost::static_log2<65536>::value;
//] [/integer_log2_example_2]
std::cout << n2 << std::endl; // 16
} // int main
/*
//[integer_log2_example_output
8
//] [/integer_log2_example_output]
*/

View File

@ -0,0 +1,69 @@
// boost integer_mask_example.cpp
// Copyright Paul A. Bristow 2015
// 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)
// Caution: this file contains Quickbook markup as well as code
// and comments, don't change any of the special comment markups!
//[integer_mask_example_0
#include <boost/integer/integer_mask.hpp> // For boost::high_bit_mask_t etc
//] [/integer_masks_example_0]
#include <iostream>
#include <limits> // for numeric_limits min and max.
//[integer_mask_example_
//] [/integer_masks_example_]
int main()
{
//[integer_mask_example_1
typedef boost::high_bit_mask_t<29> mask1_type;
typedef boost::low_bits_mask_t<15> mask2_type;
//] [/integer_masks_example_1]
//[integer_mask_example_2
// high_bit_mask_t
std::cout << std::hex << mask1_type::bit_position << std::endl; // 1d
std::cout << std::hex << mask1_type::high_bit << std::endl; // 20000000
std::cout << std::hex << mask1_type::high_bit_fast << std::endl; // 20000000
// low_bits_mask_t
std::cout << std::hex << mask2_type::bit_count << std::endl; // F
std::cout << std::hex << mask2_type::sig_bits << std::endl; // 7fff
std::cout << std::hex << mask2_type::sig_bits_fast << std::endl; // 7fff
//] [/integer_masks_example_2]
//[integer_mask_example_3
mask1_type::least my_var1;
mask2_type::fast my_var2;
//] [/integer_masks_example_3]
//[integer_mask_example_4
my_var1 |= mask1_type::high_bit;
std::cout << std::hex << my_var1 << std::endl; // eccccccc
//] [/integer_masks_example_4]
//[integer_mask_example_5
my_var2 &= mask2_type::sig_bits;
std::cout << std::hex << my_var2 << std::endl; // 4ccc
//] [/integer_masks_example_5]
} // int main
/*
//[integer_mask_example_output
1d
20000000
20000000
f
7fff
7fff
eccccccc
4ccc
//] [/integer_mask_example_output]
*/

View File

@ -0,0 +1,73 @@
// boost integer_static_minmax_example.cpp
// Copyright Paul A. Bristow 2015
// 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)
// Caution: this file contains Quickbook markup as well as code
// and comments, don't change any of the special comment markups!
#include <boost/integer/static_min_max.hpp> // For boost::static_signed_min
#include <iostream>
#include <limits> // for numeric_limits min and max.
//[integer_min_max_example_0
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;
}; // class adder
//] [/integer_min_max_example_0]
int main()
{
//[integer_min_max_example_1
std::cout << "boost::static_signed_min< 9, 14>::value = "<< boost::static_signed_min< 9, 14>::value << std::endl;
std::cout << "boost::static_signed_max< 9, 14>::value = "<< boost::static_signed_max< 9, 14>::value << std::endl;
//] [/integer_min_max_example_1]
//[integer_min_max_example_2
int const a1[] = { 0, 4, 3 }; // 340
int const a2[] = { 9, 8 }; // 89
int s[4];
adder<3, 2> obj;
// adder<sizeof(a1), sizeof(a2)> obj;
std::cout << "obj.addend1_size = " << obj.addend1_size << std::endl; // 3
std::cout << "obj.addend2_size = " << obj.addend2_size << std::endl; // 2
std::cout << "obj.sum_size = " << obj.sum_size << std::endl; // 4
//] [/integer_min_max_example_2]
// obj(a1, a2, s); // 's' should be 429 or { 9, 2, 4, 0 }
//void adder<3,2>::operator()(int const (&)[3],int const (&)[2],int (&)[4])const
std::cout << s[0] << s[1] << s[2] << s[3]<< std::endl; // 's' should be 429 or { 9, 2, 4, 0 }
} // int main
/*
//[integer_min_max_example_output
boost::static_signed_min< 9, 14>::value = 9
boost::static_signed_max< 9, 14>::value = 14
obj.addend1_size = 3
obj.addend2_size = 2
obj.sum_size = 4
//] [/integer_min_max_example_output]
*/

View File

@ -0,0 +1,55 @@
// boost integer_traits_example.cpp
// Copyright Paul A. Bristow 2015
// 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)
// Caution: this file contains Quickbook markup as well as code
// and comments, don't change any of the special comment markups!
#include <boost/integer_traits.hpp>
#include <iostream>
#include <limits> // for numeric_limits min and max.
//[integer_traits_example_1
template<int N>
void f()
{ // Entirely contrived templated function.
std::cout << N << std::endl; // Do something pointless.
}
//] [/integer_traits_example_1]
int main()
{
std::cout << "Type int, min = "
<< (std::numeric_limits<int>::min)()
<< ", const_min = " << boost::integer_traits<int>::const_min
<< std::endl; // Type int, min = -2147483648, const_min = -2147483648
//[integer_traits_example_2
f<2>();
//] [/integer_traits_example_2]
//[integer_traits_example_3
int i = 2;
// f<i>(); // A local variable cannot be used as a non-type argument.
//] [/integer_traits_example_3]
//[integer_traits_example_4
const int ci = 2;
f<ci>(); // But a const variable can.
//] [/integer_traits_example_4]
//[integer_traits_example_5
// f<std::numeric_limits<int>::min()>(); // Function call must have a constant value in a constant expression.
//] [/integer_traits_example_5]
//[integer_traits_example_6
f<boost::integer_traits<int>::const_min>();
//] [/integer_traits_example_6]
} // int main

View File

@ -0,0 +1,251 @@
// boost integer_type_selection.cpp
// Copyright Paul A. Bristow 2015
// 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)
// Caution: this file contains Quickbook markup as well as code
// and comments, don't change any of the special comment markups!
#include <boost/integer.hpp>
#include <iostream>
#include <limits> // for numeric_limits min and max.
// Note use of extra brackets to avoid potential clash for any min and max macros:
// (std::numeric_limits<T>::max)() (std::numeric_limits<T>::min)()
//! Show info about type
template <const int Bits, typename T>
void show_type()
{
std::cout << typeid(T).name()
<< " is a signed int using at least " << Bits << " bits uses "
<< std::numeric_limits<boost::int_t<Bits>::least>::digits
<< " bits, needing at most "
<< std::numeric_limits<boost::int_t<Bits>::least>::digits10
<< " decimal digits, " " and representing a maximum decimal value of "
<< static_cast<int>((std::numeric_limits<boost::int_t<Bits>::least>::max)())
<< std::endl;
} // template <const int Bits, typename T> void show_type()
template <typename T>
void show_consts()
{ //
std::cout << "Type " << typeid(T).name();
if (std::numeric_limits<T>::is_specialized)
{
std::cout << " is specialized for std::numeric_limits,";
if (std::numeric_limits<T>::is_integer)
{
std::cout << " and is integer type." << std::endl;
// If a constant expression for `min` and `max` are required, see
// Boost integer_traits.
std::cout << "const_max = " << boost::integer_traits<T>::const_max << std::endl;
std::cout << "const_min = " << boost::integer_traits<T>::const_min << std::endl;
}
}
} // void show_consts()
template <typename T>
void show_type()
{
std::cout << "Type " << typeid(T).name(); // name of resultant type.
if (std::numeric_limits<T>::is_specialized)
{
if (std::numeric_limits<T>::is_integer)
{
std::cout << " is an unsigned int with at least 13 bits using "
<< std::numeric_limits<T>::digits + (std::numeric_limits<T>::is_signed ? 1 : 0) << " bits,\n"
// See http://en.cppreference.com/w/cpp/types/numeric_limits/digits for details on the meaning of digits10.
// The value of std::numeric_limits<T>::digits is the number of digits in base-radix that can be represented
// by the type T without change.
// For integer types, this is the number of bits *not counting the sign bit*, so add one for the total.
// (For floating-point types, this is the number of digits in the mantissa).
"guaranteeing at most " << std::numeric_limits<T>::digits10 << " decimal digits precision,\n"
"and using at most " << std::numeric_limits<T>::digits10 + 1
<< " decimal digits,\n"
// See http://en.cppreference.com/w/cpp/types/numeric_limits/digits10 for details on the meaning of digits10.
// The value of std::numeric_limits<T>::digits is the number of digits in base-radix that can be represented
// by the type T without change.
// For integer types, the maximum number of digits that may be required is one more than digits10.
"a maximum decimal value of " << static_cast<long>((std::numeric_limits<T>::max)())
<< " and a minimum decimal value of " << static_cast<long>((std::numeric_limits<T>::min)()) << "."
<< std::endl;
}
else
{
std::cout << "is floating-point." << std::endl;
}
}
else
{ // is NOT specialized.
std::cout << " is NOT specialized for std::numeric_limits!" << std::endl;
}
} // template <typename T> void show_type()
template <typename T>
void show_type_limits()
{ //
std::cout <<"Type " << typeid(T).name();
if (std::numeric_limits<T>::is_specialized)
{
std::cout << " is specialized for std::numeric_limits." << std::endl;
if (std::numeric_limits<T>::is_integer)
{
std::cout << "is integer." << std::endl;
std::cout << (std::numeric_limits<T>::is_bounded ? "is bounded." : "") << std::endl;
std::cout << (std::numeric_limits<T>::is_exact ? "is exact." : "") << std::endl;
std::cout << (std::numeric_limits<T>::is_modulo ? "is modulo." : "") << std::endl;
std::cout << "radix = " << std::numeric_limits<T>::radix << std::endl;
std::cout << (std::numeric_limits<T>::is_signed ? "is signed." : "is unsigned.") << std::endl;
std::cout << "max = " << static_cast<long>((std::numeric_limits<T>::max)()) << std::endl;
std::cout << "min = " << static_cast<long>((std::numeric_limits<T>::min)()) << std::endl;
// Can't list const_max or const_min here because compiler will protest that
// const_max' : is not a member of 'boost::integer_traits<T>' when T is double.
//std::cout << "const_max = " << boost::integer_traits<T>::const_max << std::endl;
//std::cout << "const_min = " << boost::integer_traits<T>::const_min << std::endl;
std::cout << "digits = " << std::numeric_limits<T>::digits << std::endl;
std::cout << "bits = " << std::numeric_limits<T>::digits +1 << std::endl;
// digits is the number of bits not counting the sign bit for integer types.
std::cout << "digits10 = " << std::numeric_limits<T>::digits10 << std::endl;
// max_digits10 is not defined for integer types.
//std::cout << "max_digits10 = " << std::numeric_limits<T>::max_digits10 << std::endl;
}
else
{ // Not integral, so might be floating-point, or ?
std::cout << "is NOT integral type." << std::endl;
if ((std::numeric_limits<T>::max_exponent != 0) && (std::numeric_limits<T>::max_exponent10 != 0))
{ // floating-point type including fundamental float, double and multiprecision like cpp_dec_float_50 and cpp_bin_float_50.
std::cout << "is floating-point type." << std::endl;
std::cout << "digits = " << std::numeric_limits<T>::digits << std::endl;
// digits is the number of bits in the significand (not counting the sign bit) for floating-point types.
std::cout << "digits10 = " << std::numeric_limits<T>::digits10 << std::endl;
// http://en.cppreference.com/w/cpp/types/numeric_limits/digits10
std::cout << "max_digits10 = " << std::numeric_limits<T>::max_digits10 << std::endl;
std::cout << "is_modulo = " << std::numeric_limits<T>::is_modulo << std::endl;
std::cout << "is_iec559 = " << std::numeric_limits<T>::is_iec559 << std::endl;
std::cout << (std::numeric_limits<T>::is_exact ? "is exact." : "") << std::endl;
std::cout << (std::numeric_limits<T>::is_signed ? "is signed." : "is unsigned.") << std::endl;
std::cout << "has_quiet_NaN = " << std::numeric_limits<T>::has_quiet_NaN << std::endl;
std::cout << "has_infinity = " << std::numeric_limits<T>::has_infinity << std::endl;
std::cout << "has_denorm_loss = " << std::numeric_limits<T>::has_denorm_loss << std::endl;
std::cout << "max_exponent = " << std::numeric_limits<T>::max_exponent << std::endl;
std::cout << "min_exponent = " << std::numeric_limits<T>::min_exponent << std::endl;
std::cout << "max_exponent10 = " << std::numeric_limits<T>::max_exponent10 << std::endl;
std::cout << "min_exponent10 = " << std::numeric_limits<T>::min_exponent10 << std::endl;
}
else
{ // Unknown type
std::cout << "Unknown type." << std::endl;
}
}
}
else
{ // Not specialized!
std::cout << " is NOT specialized for std::numeric_limits!" << std::endl;
}
} // show_type_limits
int main()
{
try
{
// Select, construct and assign an unsigned integer of at least 13 bits.
//[integer_type_selection_1
boost::uint_t<13>::least my_var13 = 42;
//] [/integer_type_selection_1]
//[integer_type_selection_2
show_type<boost::uint_t<13>::least>();
//] [/integer_type_selection_2]
// Select fastest signed integer of at least 7 bits.
//[integer_type_selection_3
typedef boost::int_t<7>::fast int_7;
//] [/integer_type_selection_3]
//[integer_type_selection_4
show_type<int_7>();
//] [/integer_type_selection_4]
// Choose an integer size that can hold at least a value of 1000
// Assignment of this value is guaranteed not to be truncated:
//[integer_value_type_selection_5
boost::int_max_value_t<1000>::least thousand = 1000;
//] [/integer_value_type_selection_5]
std::cout << thousand << std::endl;
//[integer_value_type_selection_6
std::cout << (std::numeric_limits<boost::int_max_value_t<1000>::least>::max)() << std::endl;
//] [/integer_value_type_selection_6]
//[integer_value_type_selection_7
thousand = 100000; // Probably too big!
// warning C4305 : warning C4305: '=' : truncation from 'int' to 'short'
// warning C4309: '=' : truncation of constant value
//] [/integer_value_type_selection_7]
//[integer_value_type_selection_8
boost::int_t<32>::exact my_exact32 = 1000000;
std::cout << "boost::int_t<32>::exact has "
<< std::numeric_limits<boost::int_t<32>::exact>::digits
<< " bits and 1 sign bit." << std::endl;
// boost::int_t<32>::exact has 31 bits and 1 sign bit.
//] [/integer_value_type_selection_8]
// If we ask for an unachievable number of bits or value
//boost::int_t<128>::exact exact128;
//error C2338 : No suitable signed integer type with the requested number of bits is available.
// see reference to class template instantiation 'boost::int_t<128>' being compiled
show_consts<boost::int_t<32>::exact>();
// const_max = 2147483647 const_min = -2147483648
show_type<16, boost::int_max_value_t<1000>::least>();
}
catch (std::exception ex)
{
std::cout << ex.what() << std::endl;
}
return 0;
} // int main
/*
//[integer_type_selection_output_1
Type short is an unsigned int with at least 13 bits using 16 bits,
guaranteeing at most 4 decimal digits precision,
and using at most 5 decimal digits,
//] [/integer_type_selection_output_1]
//[integer_type_selection_output_2
Type signed char is an unsigned int with at least 13 bits using 8 bits,
guaranteeing at most 2 decimal digits precision,
and using at most 3 decimal digits,
a maximum decimal value of 127 and a minimum decimal value of -128.
//] [/integer_type_selection_output_2]
*/

33
example/jamfile.v2 Normal file
View File

@ -0,0 +1,33 @@
# libs/integer/example Jamfile
# Copyright (c) Vladimir Batov 2009-2014
# Copyright Paul A. Bristow 2015
# Distributed under the Boost Software License, Version 1.0.
# See copy at http://www.boost.org/LICENSE_1_0.txt.
# bring in the rules for testing
import testing ;
project convert_examples
: requirements
<warnings>on
<toolset>gcc:<warnings>all
<toolset>msvc:<warnings>all
<toolset>gcc:<cxxflags>"-Wno-unused-local-typedefs -Wno-unused-variable -Wno-long-long"
<toolset>msvc:<cxxflags>"/wd4996 /wd4512 /wd4610 /wd4510 /wd4127 /wd4701 /wd4127 /wd4305 /wd4100 /wd4512 /wd4714"
<toolset>msvc:<asynch-exceptions>on
<toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
<toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
<include>../include
;
run integer_mask_example.cpp ;
run integer_traits_example.cpp ;
run integer_type_selection_example.cpp ;

View File

@ -2,9 +2,12 @@
// Copyright Beman Dawes and Daryle Walker 1999. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org/libs/integer for documentation.
// See http://www.boost.org/libs/integer for documentation.
//! \file
//! \brief Compile-time evaluation of specified (least and fast) integer types.
// Revision History
// 22 Sep 01 Added value-based integer templates. (Daryle Walker)
@ -48,6 +51,7 @@ namespace boost
typedef fast type;
}; // imps may specialize
//! \cond DETAIL
namespace detail{
// convert category to type
@ -91,8 +95,7 @@ namespace boost
template <> struct exact_signed_base_helper<sizeof(int)* CHAR_BIT> { typedef int exact; };
template <> struct exact_unsigned_base_helper<sizeof(unsigned int)* CHAR_BIT> { typedef unsigned int exact; };
#endif
#if ULONG_MAX != UINT_MAX && ( !defined __TI_COMPILER_VERSION__ || \
( __TI_COMPILER_VERSION__ >= 7000000 && !defined __TI_40BIT_LONG__ ) )
#if ULONG_MAX != UINT_MAX
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
@ -105,8 +108,8 @@ namespace boost
template <> struct exact_unsigned_base_helper<sizeof(boost::ulong_long_type)* CHAR_BIT> { typedef boost::ulong_long_type exact; };
#endif
} // namespace detail
//! \endcond // DETAIL
// integer templates specifying number of bits ---------------------------//
@ -137,7 +140,7 @@ namespace boost
{
BOOST_STATIC_ASSERT_MSG(Bits <= (int)(sizeof(boost::uintmax_t) * CHAR_BIT),
"No suitable unsigned integer type with the requested number of bits is available.");
#if (defined(BOOST_BORLANDC) || defined(__CODEGEAR__)) && defined(BOOST_NO_INTEGRAL_INT64_T)
#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 +
@ -167,7 +170,7 @@ namespace boost
// integer templates specifying extreme value ----------------------------//
// signed
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
#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
@ -176,7 +179,7 @@ namespace boost
{
typedef typename boost::detail::int_least_helper
<
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
(MaxValue <= ::boost::integer_traits<boost::long_long_type>::const_max) +
#else
1 +
@ -189,7 +192,7 @@ namespace boost
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)
#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
@ -198,7 +201,7 @@ namespace boost
{
typedef typename boost::detail::int_least_helper
<
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
(MinValue >= ::boost::integer_traits<boost::long_long_type>::const_min) +
#else
1 +
@ -219,7 +222,7 @@ namespace boost
#endif
struct uint_value_t
{
#if (defined(BOOST_BORLANDC) || defined(__CODEGEAR__))
#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 =
@ -256,7 +259,6 @@ namespace boost
typedef typename int_fast_t<least>::type fast;
};
} // namespace boost
#endif // BOOST_INTEGER_HPP

View File

@ -3,9 +3,11 @@
// (C) Copyright Daryle Walker 2001-2002.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// http://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org for updates, documentation, and revision history.
// See http://www.boost.org for updates, documentation, and revision history.
//! \file
//! \brief Include both GCD and LCM.
#ifndef BOOST_INTEGER_COMMON_FACTOR_HPP
#define BOOST_INTEGER_COMMON_FACTOR_HPP

View File

@ -3,23 +3,27 @@
// (C) Copyright Daryle Walker and Stephen Cleary 2001-2002.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// http://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org for updates, documentation, and revision history.
// See http://www.boost.org for updates, documentation, and revision history.
//! \file
//! \brief Evaluate Greatest Common Divisor and Least Common Multiple at compile-time.
#ifndef BOOST_INTEGER_COMMON_FACTOR_CT_HPP
#define BOOST_INTEGER_COMMON_FACTOR_CT_HPP
#include <boost/integer_fwd.hpp> // self include
#include <boost/integer_fwd.hpp> // Include for declaration of static_gcd_type and static_gcd.
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT, etc.
#include <boost/cstdint.hpp> // for boost::uintmax_t
namespace boost
{
namespace integer
{
// Warning: From 1.58 this is in namespace boost::integer and no longer in namespace boost::math.
// Implementation details --------------------------------------------------//
//! \cond DETAIL
namespace detail
{
// Build GCD with Euclid's recursive algorithm
@ -30,7 +34,7 @@ namespace detail
BOOST_STATIC_CONSTANT( static_gcd_type, new_value1 = Value2 );
BOOST_STATIC_CONSTANT( static_gcd_type, new_value2 = Value1 % Value2 );
#ifndef BOOST_BORLANDC
#ifndef __BORLANDC__
#define BOOST_DETAIL_GCD_HELPER_VAL(Value) static_cast<static_gcd_type>(Value)
#else
typedef static_gcd_helper_t self_type;
@ -71,7 +75,7 @@ namespace detail
};
} // namespace detail
//! \endcond // DETAIL
// Compile-time greatest common divisor evaluator class declaration --------//

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,117 +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
// Copyright (c) 2022 Andrey Semashev
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// http://www.boost.org/LICENSE_1_0.txt)
//
//! \file
//! \brief Function integer_log2 gives the integer part of the logarithm, in base 2, of a
//! given number (at run-time). Behavior is undefined if the argument is <= 0.
//
//! \note For analogous compile-time computation of log2 see static_log2.
//! \sa http::www.boost.org/doc/integer
// -----------------------------------------------------------
#ifndef BOOST_INTEGER_INTEGER_LOG2_HPP
#define BOOST_INTEGER_INTEGER_LOG2_HPP
#include <assert.h>
#ifdef __BORLANDC__
#include <climits>
#include <limits>
#endif
#include <boost/limits.hpp>
#include <boost/config.hpp>
#include <boost/assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/core/bit.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/make_unsigned.hpp>
namespace boost {
namespace detail {
// helper to find the maximum power of two
// less than p
template< unsigned int p, unsigned int n, bool = ((2u * n) < p) >
struct max_pow2_less :
public max_pow2_less< p, 2u * n >
{
};
//! \cond DETAIL
namespace detail {
template< unsigned int p, unsigned int n >
struct max_pow2_less< p, n, false >
{
BOOST_STATIC_CONSTANT(unsigned int, value = n);
};
template< typename T >
inline typename boost::disable_if< boost::is_integral< T >, int >::type integer_log2_impl(T x)
{
unsigned int n = detail::max_pow2_less<
std::numeric_limits< T >::digits,
CHAR_BIT / 2u
>::value;
template <typename T>
int integer_log2_impl(T x, int n) {
int result = 0;
while (x != 1)
{
T t(x >> n);
if (t)
{
result += static_cast< int >(n);
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
x = static_cast< T&& >(t);
#else
while (x != 1) {
const T t = static_cast<T>(x >> n);
if (t) {
result += n;
x = t;
#endif
}
n >>= 1u;
n /= 2;
}
return result;
}
}
template< typename T >
inline typename boost::enable_if< boost::is_integral< T >, int >::type integer_log2_impl(T x)
{
// We could simply rely on numeric_limits but sometimes
// 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
return static_cast< int >((sizeof(T) * CHAR_BIT - 1u) -
boost::core::countl_zero(static_cast< typename boost::make_unsigned< T >::type >(x)));
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
//! \endcond // 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);
}
}
#if defined(BOOST_HAS_INT128)
// We need to provide explicit overloads for __int128 because (a) boost/core/bit.hpp currently does not support it and
// (b) std::numeric_limits are not specialized for __int128 in some standard libraries.
inline int integer_log2_impl(boost::uint128_type x)
{
const boost::uint64_t x_hi = static_cast< boost::uint64_t >(x >> 64u);
if (x_hi != 0u)
return 127 - boost::core::countl_zero(x_hi);
else
return 63 - boost::core::countl_zero(static_cast< boost::uint64_t >(x));
}
inline int integer_log2_impl(boost::int128_type x)
{
return detail::integer_log2_impl(static_cast< boost::uint128_type >(x));
}
#endif // defined(BOOST_HAS_INT128)
} // namespace detail
// ------------
// integer_log2
// ------------
template< typename T >
inline int integer_log2(T x)
{
BOOST_ASSERT(x > 0);
return detail::integer_log2_impl(x);
}
} // namespace boost
#endif // BOOST_INTEGER_INTEGER_LOG2_HPP
#endif // BOOST_INTEGER_INTEGER_LOG2_HPP include guard

View File

@ -3,9 +3,12 @@
// (C) Copyright Daryle Walker 2001.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// http://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org for updates, documentation, and revision history.
// See http://www.boost.org for updates, documentation, and revision history.
//! \file
//! \brief Compile-time integer mask evaluation.
#ifndef BOOST_INTEGER_INTEGER_MASK_HPP
#define BOOST_INTEGER_INTEGER_MASK_HPP
@ -35,7 +38,6 @@
namespace boost
{
// Specified single-bit mask class declaration -----------------------------//
// (Lowest bit starts counting at 0.)
@ -57,27 +59,19 @@ struct high_bit_mask_t
// Makes masks for the lowest N bits
// (Specializations are needed when N fills up a type.)
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4310) // cast truncates constant value
#endif
template < std::size_t Bits >
struct low_bits_mask_t
{
typedef typename uint_t<Bits>::least least;
typedef typename uint_t<Bits>::fast fast;
BOOST_STATIC_CONSTANT( least, sig_bits = least(~(least(~(least( 0u ))) << Bits )) );
BOOST_STATIC_CONSTANT( least, sig_bits = (~( ~(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 > { \

View File

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

View File

@ -6,21 +6,27 @@
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// http://www.boost.org/LICENSE_1_0.txt)
//
// ---------------------------------------------------
// See https://www.boost.org/libs/integer for documentation.
// See http://www.boost.org/libs/integer for documentation.
//! \file
//! \brief Compile-time calculation of integer part of the logarithm, in base 2, of a given number.
//! \note For a run-time calculation of log2, see function integer_log2 at integer_log2.hpp.
// ------------------------------------------------------------------------- //
#ifndef BOOST_INTEGER_STATIC_LOG2_HPP
#define BOOST_INTEGER_STATIC_LOG2_HPP
#include <boost/config.hpp>
#include <boost/integer_fwd.hpp>
#include "boost/integer_fwd.hpp" // for boost::intmax_t
namespace boost {
//! \cond DETAIL
namespace detail {
namespace static_log2_impl {
@ -100,8 +106,7 @@ namespace boost {
}
} // detail
//! \endcond // DETAIL
// --------------------------------------
// static_log2<x>
@ -121,6 +126,8 @@ namespace boost {
template <>
struct static_log2<0> { };
}
} // namespace boost
#endif // include guard

View File

@ -3,14 +3,15 @@
// (C) Copyright Daryle Walker 2001.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// http://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org for updates, documentation, and revision history.
// See http://www.boost.org for updates, documentation, and revision history.
//! \file
//! \brief Compile-time evaluation of extrema: minimum or maximum of two values, signed or unsigned.
#ifndef BOOST_INTEGER_STATIC_MIN_MAX_HPP
#define BOOST_INTEGER_STATIC_MIN_MAX_HPP
#include <boost/config.hpp>
#include <boost/integer_fwd.hpp> // self include
namespace boost

View File

@ -2,9 +2,11 @@
// (C) Copyright Dave Abrahams and Daryle Walker 2001. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org/libs/integer for documentation.
// See http://www.boost.org/libs/integer for documentation.
//! \file
//! \brief Include all Boost.Integer files.
#ifndef BOOST_INTEGER_FWD_HPP
#define BOOST_INTEGER_FWD_HPP
@ -16,7 +18,6 @@
#include <boost/limits.hpp> // for std::numeric_limits
#include <boost/cstdint.hpp> // For intmax_t
namespace boost
{
@ -158,9 +159,9 @@ template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Valu
template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
struct static_unsigned_max;
namespace integer
{
// From <boost/integer/common_factor_ct.hpp>
#ifdef BOOST_NO_INTEGRAL_INT64_T
@ -182,7 +183,7 @@ template < typename IntegerType >
template < typename IntegerType >
class lcm_evaluator;
} // namespace integer
] // namespace integer
} // namespace boost

View File

@ -3,14 +3,19 @@
* Copyright Jens Maurer 2000
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* https://www.boost.org/LICENSE_1_0.txt)
* http://www.boost.org/LICENSE_1_0.txt)
*
* $Id$
*
* Idea by Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers
*/
// See https://www.boost.org/libs/integer for documentation.
// See http://www.boost.org/libs/integer for documentation.
//! \file
//! \brief integer traits
//! \sa http://www.boost.org/libs/integer
#ifndef BOOST_INTEGER_TRAITS_HPP
@ -47,6 +52,7 @@ public:
BOOST_STATIC_CONSTANT(bool, is_integral = false);
};
//! \cond DETAIL
namespace detail {
template<class T, T min_val, T max_val>
class integer_traits_base
@ -70,6 +76,7 @@ const T integer_traits_base<T, min_val, max_val>::const_max;
#endif
} // namespace detail
//! \endcond // DETAIL
template<>
class integer_traits<bool>
@ -103,7 +110,7 @@ class integer_traits<wchar_t>
// 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(BOOST_BORLANDC) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__BEOS__) && defined(__GNUC__))
#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))\

View File

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

View File

@ -7,7 +7,7 @@ Automatic redirection failed, please go to
<a href="doc/html/index.html">doc/html/index.html</a>.
<P>Copyright Beman Dawes, Daryle Walker, Gennaro Prota and John Maddock 2001-2009</P>
<P>Distributed under the Boost Software License, Version 1.0. (See accompanying file <A href="../../LICENSE_1_0.txt">
LICENSE_1_0.txt</A> or copy at <A href="https://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</A>).</P>
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>

View File

@ -7,8 +7,6 @@
],
"authors": "",
"maintainers": [
"Daryle Walker <darylew -at- hotmail.com>",
"Andrey Semashev <andrey.semashev -at- gmail.com>"
],
"cxxstd": "03"
"Daryle Walker <darylew -at- hotmail.com>"
]
}

View File

@ -1,42 +1,29 @@
#~ Copyright Rene Rivera 2008
#~ Distributed under the Boost Software License, Version 1.0.
#~ (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#~ (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
require-b2 5.0.1 ;
import-search /boost/config/checks ;
import config : requires ;
import testing ;
project : requirements <warnings>all <toolset>gcc:<cxxflags>-Wextra
<library>/boost/integer//boost_integer ;
obj has_gmpxx : has_gmpxx.cpp ;
explicit has_gmpxx ;
project : requirements <warnings>all <toolset>gcc:<cxxflags>-Wextra ;
test-suite integer
:
[ run integer_traits_test.cpp ]
[ run integer_test.cpp : : : <library>/boost/mpl//boost_mpl <toolset>gcc:<cxxflags>-Wno-long-long <toolset>darwin:<cxxflags>-Wno-long-long <toolset>sun:<cxxflags>"-Qoption ccfe -tmpldepth=128" ]
[ run integer_mask_test.cpp : : : <library>/boost/detail//boost_detail ]
[ run integer_log2_test.cpp : : : <library>/boost/multiprecision//boost_multiprecision ]
[ run static_log2_test.cpp : : : <library>/boost/detail//boost_detail ]
[ run static_min_max_test.cpp : : : <library>/boost/detail//boost_detail ]
[ run extended_euclidean_test.cpp : : : <library>/boost/multiprecision//boost_multiprecision ]
[ run mod_inverse_test.cpp : : : <library>/boost/optional//boost_optional <library>/boost/multiprecision//boost_multiprecision ]
[ 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 : <library>/boost/detail//boost_detail ]
[ 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 : : : <library>/boost/mpl//boost_mpl <library>/boost/random//boost_random <library>/boost/rational//boost_rational <library>/boost/multiprecision//boost_multiprecision [ check-target-builds has_gmpxx "Checking for gmpxx.h" : <define>BOOST_INTEGER_HAS_GMPXX_H=1 <linkflags>-lgmp <linkflags>-lgmpxx ] ]
[ run common_factor_test.cpp ]
;

View File

@ -3,9 +3,9 @@
// (C) Copyright Daryle Walker 2001, 2006.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// http://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org for most recent version including documentation.
// 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)
@ -15,31 +15,19 @@
// 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"
#define BOOST_TEST_MAIN "Boost.Math GCD & LCM unit tests"
#include <boost/integer/common_factor.hpp>
#include <boost/config.hpp> // for BOOST_MSVC, etc.
#include <boost/detail/workaround.hpp>
#include <boost/integer/common_factor.hpp> // for boost::integer::gcd, etc.
#include <boost/mpl/list.hpp> // for boost::mpl::list
#include <boost/operators.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/rational.hpp>
#include <istream> // for std::basic_istream
#include <limits> // for std::numeric_limits
#include <ostream> // for std::basic_ostream
#ifdef BOOST_INTEGER_HAS_GMPXX_H
#include <gmpxx.h>
#endif
#include "multiprecision_config.hpp"
#ifndef DISABLE_MP_TESTS
#include <boost/multiprecision/cpp_int.hpp>
#endif
namespace {
@ -121,29 +109,6 @@ 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 /**/
@ -255,7 +220,7 @@ public:
#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
// MSVC 6.0 lacks operator<< for __int64, see
// https://support.microsoft.com/kb/168440/
// http://support.microsoft.com/default.aspx?scid=kb;en-us;168440
inline ostream& operator<<(ostream& os, __int64 i)
{
@ -281,330 +246,199 @@ inline ostream& operator<<(ostream& os, unsigned __int64 i)
// 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));
BOOST_TEST_EQ( gcd<T>( 1, -1), static_cast<T>( 1) );
BOOST_TEST_EQ( gcd<T>( -1, 1), static_cast<T>( 1) );
BOOST_TEST_EQ( gcd<T>( 1, 1), static_cast<T>( 1) );
BOOST_TEST_EQ( gcd<T>( -1, -1), static_cast<T>( 1) );
BOOST_TEST_EQ( gcd<T>( 0, 0), static_cast<T>( 0) );
BOOST_TEST_EQ( gcd<T>( 7, 0), static_cast<T>( 7) );
BOOST_TEST_EQ( gcd<T>( 0, 9), static_cast<T>( 9) );
BOOST_TEST_EQ( gcd<T>( -7, 0), static_cast<T>( 7) );
BOOST_TEST_EQ( gcd<T>( 0, -9), static_cast<T>( 9) );
BOOST_TEST_EQ( gcd<T>( 42, 30), static_cast<T>( 6) );
BOOST_TEST_EQ( gcd<T>( 6, -9), static_cast<T>( 3) );
BOOST_TEST_EQ( gcd<T>(-10, -10), static_cast<T>(10) );
BOOST_TEST_EQ( gcd<T>(-25, -10), static_cast<T>( 5) );
BOOST_TEST_EQ( gcd<T>( 3, 7), static_cast<T>( 1) );
BOOST_TEST_EQ( gcd<T>( 8, 9), static_cast<T>( 1) );
BOOST_TEST_EQ( gcd<T>( 7, 49), static_cast<T>( 7) );
}
// GCD on unmarked signed integer type
void gcd_unmarked_int_test()
{
#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) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 1, -1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( -1, 1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 1, 1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( -1, -1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 0, 0 )), MyInt2( 0) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 7, 0 )), MyInt2( 7) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 0, 9 )), MyInt2( 9) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( -7, 0 )), MyInt2( 7) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 0, -9 )), MyInt2( 9) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 42, 30 )), MyInt2( 6) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 6, -9 )), MyInt2( 3) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( -10, -10 )), MyInt2(10) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( -25, -10 )), MyInt2( 5) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 3, 7 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 8, 9 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(gcd<MyInt2>( 7, 49 )), MyInt2( 7) );
}
// GCD on unsigned integer types
template< class T > void gcd_unsigned_test() // unsigned_test_types
{
#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) );
BOOST_TEST_EQ( gcd<T>( 1u, 1u), static_cast<T>( 1u) );
BOOST_TEST_EQ( gcd<T>( 0u, 0u), static_cast<T>( 0u) );
BOOST_TEST_EQ( gcd<T>( 7u, 0u), static_cast<T>( 7u) );
BOOST_TEST_EQ( gcd<T>( 0u, 9u), static_cast<T>( 9u) );
BOOST_TEST_EQ( gcd<T>(42u, 30u), static_cast<T>( 6u) );
BOOST_TEST_EQ( gcd<T>( 3u, 7u), static_cast<T>( 1u) );
BOOST_TEST_EQ( gcd<T>( 8u, 9u), static_cast<T>( 1u) );
BOOST_TEST_EQ( gcd<T>( 7u, 49u), static_cast<T>( 7u) );
}
// GCD at compile-time
void gcd_static_test()
{
#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 );
BOOST_TEST_EQ( (static_gcd< 1, 1>::value), 1 );
BOOST_TEST_EQ( (static_gcd< 0, 0>::value), 0 );
BOOST_TEST_EQ( (static_gcd< 7, 0>::value), 7 );
BOOST_TEST_EQ( (static_gcd< 0, 9>::value), 9 );
BOOST_TEST_EQ( (static_gcd<42, 30>::value), 6 );
BOOST_TEST_EQ( (static_gcd< 3, 7>::value), 1 );
BOOST_TEST_EQ( (static_gcd< 8, 9>::value), 1 );
BOOST_TEST_EQ( (static_gcd< 7, 49>::value), 7 );
}
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));
// TODO: non-built-in signed and unsigned integer tests, with and without
// numeric_limits specialization; polynominal tests; note any changes if
// built-ins switch to binary-GCD algorithm
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));
BOOST_TEST_EQ( lcm<T>( 1, -1), static_cast<T>( 1) );
BOOST_TEST_EQ( lcm<T>( -1, 1), static_cast<T>( 1) );
BOOST_TEST_EQ( lcm<T>( 1, 1), static_cast<T>( 1) );
BOOST_TEST_EQ( lcm<T>( -1, -1), static_cast<T>( 1) );
BOOST_TEST_EQ( lcm<T>( 0, 0), static_cast<T>( 0) );
BOOST_TEST_EQ( lcm<T>( 6, 0), static_cast<T>( 0) );
BOOST_TEST_EQ( lcm<T>( 0, 7), static_cast<T>( 0) );
BOOST_TEST_EQ( lcm<T>( -5, 0), static_cast<T>( 0) );
BOOST_TEST_EQ( lcm<T>( 0, -4), static_cast<T>( 0) );
BOOST_TEST_EQ( lcm<T>( 18, 30), static_cast<T>(90) );
BOOST_TEST_EQ( lcm<T>( -6, 9), static_cast<T>(18) );
BOOST_TEST_EQ( lcm<T>(-10, -10), static_cast<T>(10) );
BOOST_TEST_EQ( lcm<T>( 25, -10), static_cast<T>(50) );
BOOST_TEST_EQ( lcm<T>( 3, 7), static_cast<T>(21) );
BOOST_TEST_EQ( lcm<T>( 8, 9), static_cast<T>(72) );
BOOST_TEST_EQ( lcm<T>( 7, 49), static_cast<T>(49) );
}
// LCM on unmarked signed integer type
void lcm_unmarked_int_test()
{
#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) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 1, -1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( -1, 1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 1, 1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( -1, -1 )), MyInt2( 1) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 0, 0 )), MyInt2( 0) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 6, 0 )), MyInt2( 0) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 0, 7 )), MyInt2( 0) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( -5, 0 )), MyInt2( 0) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 0, -4 )), MyInt2( 0) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 18, 30 )), MyInt2(90) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( -6, 9 )), MyInt2(18) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( -10, -10 )), MyInt2(10) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 25, -10 )), MyInt2(50) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 3, 7 )), MyInt2(21) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 8, 9 )), MyInt2(72) );
BOOST_TEST_EQ( abs(lcm<MyInt2>( 7, 49 )), MyInt2(49) );
}
// LCM on unsigned integer types
template< class T > void lcm_unsigned_test() // unsigned_test_types
{
#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) );
BOOST_TEST_EQ( lcm<T>( 1u, 1u), static_cast<T>( 1u) );
BOOST_TEST_EQ( lcm<T>( 0u, 0u), static_cast<T>( 0u) );
BOOST_TEST_EQ( lcm<T>( 6u, 0u), static_cast<T>( 0u) );
BOOST_TEST_EQ( lcm<T>( 0u, 7u), static_cast<T>( 0u) );
BOOST_TEST_EQ( lcm<T>(18u, 30u), static_cast<T>(90u) );
BOOST_TEST_EQ( lcm<T>( 3u, 7u), static_cast<T>(21u) );
BOOST_TEST_EQ( lcm<T>( 8u, 9u), static_cast<T>(72u) );
BOOST_TEST_EQ( lcm<T>( 7u, 49u), static_cast<T>(49u) );
}
// LCM at compile-time
void lcm_static_test()
{
#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 );
BOOST_TEST_EQ( (static_lcm< 1, 1>::value), 1 );
BOOST_TEST_EQ( (static_lcm< 0, 0>::value), 0 );
BOOST_TEST_EQ( (static_lcm< 6, 0>::value), 0 );
BOOST_TEST_EQ( (static_lcm< 0, 7>::value), 0 );
BOOST_TEST_EQ( (static_lcm<18, 30>::value), 90 );
BOOST_TEST_EQ( (static_lcm< 3, 7>::value), 21 );
BOOST_TEST_EQ( (static_lcm< 8, 9>::value), 72 );
BOOST_TEST_EQ( (static_lcm< 7, 49>::value), 49 );
}
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);
// TODO: see GCD to-do
unsigned i_gcd_unity[] = { 44, 56, 1, 88 };
BOOST_TEST_EQ(boost::integer::gcd_range(i_gcd_unity, i_gcd_unity + 4).first, 1);
BOOST_TEST_EQ(boost::integer::gcd_range(i_gcd_unity, i_gcd_unity + 4).second, i_gcd_unity + 3);
// main
unsigned i_lcm_unity[] = { 44, 56, 0, 88 };
BOOST_TEST_EQ(boost::integer::lcm_range(i_lcm_unity, i_lcm_unity + 4).first, 0);
BOOST_TEST_EQ(boost::integer::lcm_range(i_lcm_unity, i_lcm_unity + 4).second, i_lcm_unity + 3);
// Various types to test with each GCD/LCM
#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 ) \
# define TEST_SIGNED( test ) \
TEST_SIGNED_( test ) \
test<boost::long_long_type>();
#elif defined(BOOST_HAS_MS_INT64)
# define TEST_SIGNED__( test ) \
# 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>(); \
@ -612,7 +446,6 @@ template <class T> void gcd_and_lcm_on_rationals()
test<unsigned long>(); \
test<MyUnsigned1>(); \
test<MyUnsigned2>();
#endif
#ifdef BOOST_HAS_LONG_LONG
# define TEST_UNSIGNED( test ) \
@ -624,30 +457,17 @@ template <class T> void gcd_and_lcm_on_rationals()
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)
TEST_SIGNED( gcd_int_test )
gcd_unmarked_int_test();
TEST_UNSIGNED(gcd_unsigned_test)
TEST_UNSIGNED( gcd_unsigned_test )
gcd_static_test();
gcd_method_test();
TEST_SIGNED(lcm_int_test)
TEST_SIGNED( lcm_int_test )
lcm_unmarked_int_test();
TEST_UNSIGNED(lcm_unsigned_test)
TEST_UNSIGNED( lcm_unsigned_test )
lcm_static_test();
variadics();
TEST_SIGNED_NO_GMP(gcd_and_lcm_on_rationals)
return boost::report_errors();
}

View File

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

View File

@ -1,7 +1,7 @@
// Copyright John Maddock 2012.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp>

View File

@ -1,7 +1,7 @@
// Copyright John Maddock 2012.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp>

View File

@ -1,7 +1,7 @@
// Copyright John Maddock 2012.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp>

View File

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

View File

@ -1,7 +1,7 @@
// Copyright John Maddock 2012.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp>

View File

@ -1,7 +1,7 @@
// Copyright John Maddock 2012.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp>

View File

@ -1,7 +1,7 @@
// Copyright John Maddock 2012.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp>

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
// Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// 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!

View File

@ -1,7 +1,7 @@
// Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp> // must be the only #include!

View File

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

View File

@ -1,7 +1,7 @@
// Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// 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!

View File

@ -3,14 +3,14 @@
// (C) Copyright Daryle Walker 2001.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// http://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org for most recent version including documentation.
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 23 Sep 2001 Initial version (Daryle Walker)
#include <boost/core/lightweight_test.hpp>
#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.

View File

@ -5,20 +5,19 @@
// Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org/libs/integer for documentation.
// 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/core/lightweight_test.hpp> // for main, BOOST_TEST
#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)
@ -27,7 +26,7 @@
#ifdef BOOST_MSVC
#pragma warning(disable:4127) // conditional expression is constant
#endif
#if defined( BOOST_BORLANDC )
#if defined( __BORLANDC__ )
# pragma option -w-8008 -w-8066 // condition is always true
#endif
@ -70,7 +69,7 @@ void do_test_exact(boost::mpl::true_ const&)
template <int Bits>
void do_test_exact(boost::mpl::false_ const&)
{
// Nothing to do, type does not have an ::extact member.
// Nothing to do, type does not have an ::exact member.
}
template <int Bits>

View File

@ -1,7 +1,7 @@
// Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// 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!

View File

@ -3,7 +3,7 @@
* Copyright Jens Maurer 2000
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* https://www.boost.org/LICENSE_1_0.txt)
* http://www.boost.org/LICENSE_1_0.txt)
*
* $Id$
*
@ -17,7 +17,7 @@
// use int64_t instead of long long for better portability
#include <boost/cstdint.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_test.hpp>
/*
* General portability note:
@ -35,7 +35,6 @@ namespace fix{
inline int make_char_numeric_for_streaming(char c) { return c; }
inline int make_char_numeric_for_streaming(signed char c) { return c; }
inline int make_char_numeric_for_streaming(unsigned char c) { return c; }
inline long long int make_char_numeric_for_streaming(wchar_t c) { return c; }
}
using namespace fix;
#else
@ -43,7 +42,6 @@ template<typename T> inline T make_char_numeric_for_streaming(T x) { return x; }
inline int make_char_numeric_for_streaming(char c) { return c; }
inline int make_char_numeric_for_streaming(signed char c) { return c; }
inline int make_char_numeric_for_streaming(unsigned char c) { return c; }
inline long long int make_char_numeric_for_streaming(wchar_t c) { return c; }
#endif
template<class T>

View File

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

View File

@ -1,19 +0,0 @@
// Copyright (c) 2018, 2024 Andrey Semashev
//
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_INTEGER_TEST_MULTIPRECISION_CONFIG_HPP_INCLUDED_
#define BOOST_INTEGER_TEST_MULTIPRECISION_CONFIG_HPP_INCLUDED_
#include <boost/config.hpp>
// Boost.Multiprecision requires a number of C++11 features, see boost/multiprecision/detail/check_cpp11_config.hpp.
// Also, Boost.Multiprecision internally uses Boost.Math, which requires C++14 and a recent enough MSVC, see boost/math/tools/config.hpp.
#if (BOOST_CXX_VERSION < 201402) || \
(defined(_MSC_VER) && (_MSC_VER <= 1900))
#define DISABLE_MP_TESTS
#endif
#endif // BOOST_INTEGER_TEST_MULTIPRECISION_CONFIG_HPP_INCLUDED_

View File

@ -1,7 +1,7 @@
// Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// 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!

View File

@ -3,14 +3,14 @@
// (C) Copyright Daryle Walker 2001.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// http://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org for most recent version including documentation.
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 01 Oct 2001 Initial version (Daryle Walker)
#include <boost/core/lightweight_test.hpp> // for main
#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

View File

@ -1,7 +1,7 @@
// Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// 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!

View File

@ -3,14 +3,14 @@
// (C) Copyright Daryle Walker 2001.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// http://www.boost.org/LICENSE_1_0.txt)
// See https://www.boost.org for most recent version including documentation.
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 23 Sep 2001 Initial version (Daryle Walker)
#include <boost/core/lightweight_test.hpp> // for main, BOOST_TEST
#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.