mirror of
https://github.com/boostorg/integer.git
synced 2025-06-26 12:31:40 +02:00
Compare commits
11 Commits
doc_revisi
...
cpp14
Author | SHA1 | Date | |
---|---|---|---|
39d9701857 | |||
45cc025bbd | |||
13b36d8432 | |||
a52bae3639 | |||
13b153c657 | |||
89cec128bd | |||
175a1caa58 | |||
1ff7278d5f | |||
a12b96c011 | |||
7ffb75bb43 | |||
83feb20e51 |
103
doc/Jamfile.v2
103
doc/Jamfile.v2
@ -1,88 +1,12 @@
|
||||
# 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 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
|
||||
@ -90,7 +14,6 @@ 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:
|
||||
@ -103,7 +26,7 @@ boostbook standalone
|
||||
<xsl:param>generate.section.toc.level=4
|
||||
# Path for links to Boost:
|
||||
<xsl:param>boost.root=../../../..
|
||||
|
||||
|
||||
# PDF Options:
|
||||
# TOC Generation: this is needed for FOP-0.9 and later:
|
||||
<xsl:param>fop1.extensions=0
|
||||
@ -124,20 +47,14 @@ boostbook standalone
|
||||
# better use SVG's instead:
|
||||
<format>pdf:<xsl:param>admon.graphics.extension=".svg"
|
||||
<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.
|
||||
|
||||
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/regex/doc/html
|
||||
;
|
||||
|
||||
# install pdfinstall : standalone/<format>pdf : <location>. <install-type>PDF <name>boost.pdf ;
|
||||
|
||||
|
||||
install pdf-install : standalone : <install-type>PDF <location>. <name>integer.pdf ;
|
||||
|
||||
install pdfinstall : standalone/<format>pdf : <location>. <install-type>PDF ;
|
||||
explicit pdfinstall ;
|
||||
|
||||
|
||||
###############################################################################
|
||||
alias boostdoc ;
|
||||
explicit boostdoc ;
|
||||
alias boostrelease : standalone ;
|
||||
explicit boostrelease ;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -24,9 +24,9 @@ programming problems.
|
||||
class lcm_evaluator;
|
||||
|
||||
template < typename IntegerType >
|
||||
IntegerType gcd( IntegerType const &a, IntegerType const &b );
|
||||
constexpr IntegerType gcd( IntegerType const &a, IntegerType const &b );
|
||||
template < typename IntegerType >
|
||||
IntegerType lcm( IntegerType const &a, IntegerType const &b );
|
||||
constexpr IntegerType lcm( IntegerType const &a, IntegerType const &b );
|
||||
|
||||
typedef ``['see-below]`` static_gcd_type;
|
||||
|
||||
@ -54,8 +54,9 @@ programming problems.
|
||||
typedef IntegerType second_argument_type;
|
||||
|
||||
// Function object interface
|
||||
result_type operator ()( first_argument_type const &a,
|
||||
second_argument_type const &b ) const;
|
||||
constexpr result_type operator ()(
|
||||
first_argument_type const &a,
|
||||
second_argument_type const &b ) const;
|
||||
};
|
||||
|
||||
The boost::math::gcd_evaluator class template defines a function object
|
||||
@ -70,6 +71,9 @@ 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]
|
||||
@ -86,8 +90,9 @@ gcd_evaluator class template.
|
||||
typedef IntegerType second_argument_type;
|
||||
|
||||
// Function object interface
|
||||
result_type operator ()( first_argument_type const &a,
|
||||
second_argument_type const &b ) const;
|
||||
constexpr result_type operator ()(
|
||||
first_argument_type const &a,
|
||||
second_argument_type const &b ) const;
|
||||
};
|
||||
|
||||
The boost::math::lcm_evaluator class template defines a function object
|
||||
@ -103,6 +108,9 @@ 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]
|
||||
@ -110,10 +118,10 @@ specialize on the lcm_evaluator class template.
|
||||
[*Header: ] [@../../../../boost/math/common_factor_rt.hpp <boost/math/common_factor_rt.hpp>]
|
||||
|
||||
template < typename IntegerType >
|
||||
IntegerType boost::math::gcd( IntegerType const &a, IntegerType const &b );
|
||||
constexpr IntegerType boost::math::gcd( IntegerType const &a, IntegerType const &b );
|
||||
|
||||
template < typename IntegerType >
|
||||
IntegerType boost::math::lcm( IntegerType const &a, IntegerType const &b );
|
||||
constexpr IntegerType boost::math::lcm( IntegerType const &a, IntegerType const &b );
|
||||
|
||||
The boost::math::gcd function template returns the greatest common
|
||||
(nonnegative) divisor of the two integers passed to it.
|
||||
@ -124,6 +132,9 @@ IntegerType, which is also the return type. Internally, these function
|
||||
templates use an object of the corresponding version of the
|
||||
gcd_evaluator and lcm_evaluator class templates, respectively.
|
||||
|
||||
Note that these functions are constexpr in C++14 and later only.
|
||||
They are also declared `noexcept` when appropriate.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:compile_time Compile time GCD and LCM determination]
|
||||
|
@ -3,7 +3,7 @@
|
||||
<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">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Integer">
|
||||
<link rel="up" href="../index.html" title="Boost.Integer">
|
||||
<link rel="prev" href="history.html" title="History">
|
||||
|
@ -3,7 +3,7 @@
|
||||
<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">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Integer">
|
||||
<link rel="up" href="../index.html" title="Boost.Integer">
|
||||
<link rel="prev" href="minmax.html" title="Compile time min/max calculation">
|
||||
|
@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Integer Type Selection</title>
|
||||
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Integer">
|
||||
<link rel="up" href="../index.html" title="Boost.Integer">
|
||||
<link rel="prev" href="traits.html" title="Integer Traits">
|
||||
@ -26,7 +26,7 @@
|
||||
<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">
|
||||
<div class="toc"><dl>
|
||||
<dt><span class="section"><a href="integer.html#boost_integer.integer.synopsis">Synopsis</a></span></dt>
|
||||
<dt><span class="section"><a href="integer.html#boost_integer.integer.easiest">Easiest-to-Manipulate
|
||||
Types</a></span></dt>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Compile Time log2 Calculation</title>
|
||||
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Integer">
|
||||
<link rel="up" href="../index.html" title="Boost.Integer">
|
||||
<link rel="prev" href="mask.html" title="Integer Masks">
|
||||
@ -26,7 +26,7 @@
|
||||
<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">
|
||||
<div class="toc"><dl>
|
||||
<dt><span class="section"><a href="log2.html#boost_integer.log2.synopsis">Synopsis</a></span></dt>
|
||||
<dt><span class="section"><a href="log2.html#boost_integer.log2.usage">Usage</a></span></dt>
|
||||
<dt><span class="section"><a href="log2.html#boost_integer.log2.demonstration_program">Demonstration
|
||||
|
@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Integer Masks</title>
|
||||
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Integer">
|
||||
<link rel="up" href="../index.html" title="Boost.Integer">
|
||||
<link rel="prev" href="integer.html" title="Integer Type Selection">
|
||||
@ -26,7 +26,7 @@
|
||||
<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">
|
||||
<div class="toc"><dl>
|
||||
<dt><span class="section"><a href="mask.html#boost_integer.mask.overview">Overview</a></span></dt>
|
||||
<dt><span class="section"><a href="mask.html#boost_integer.mask.synopsis">Synopsis</a></span></dt>
|
||||
<dt><span class="section"><a href="mask.html#boost_integer.mask.single_bit_mask_class_template">Single
|
||||
|
@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Compile time min/max calculation</title>
|
||||
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Integer">
|
||||
<link rel="up" href="../index.html" title="Boost.Integer">
|
||||
<link rel="prev" href="log2.html" title="Compile Time log2 Calculation">
|
||||
@ -26,7 +26,7 @@
|
||||
<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">
|
||||
<div class="toc"><dl>
|
||||
<dt><span class="section"><a href="minmax.html#boost_integer.minmax.synopsis">Synopsis</a></span></dt>
|
||||
<dt><span class="section"><a href="minmax.html#boost_integer.minmax.usage">Usage</a></span></dt>
|
||||
<dt><span class="section"><a href="minmax.html#boost_integer.minmax.example">Example</a></span></dt>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<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">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Integer">
|
||||
<link rel="up" href="../index.html" title="Boost.Integer">
|
||||
<link rel="prev" href="../index.html" title="Boost.Integer">
|
||||
@ -26,7 +26,7 @@
|
||||
<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">
|
||||
<div class="toc"><dl>
|
||||
<dt><span class="section"><a href="traits.html#boost_integer.traits.motivation">Motivation</a></span></dt>
|
||||
<dt><span class="section"><a href="traits.html#boost_integer.traits.synopsis">Synopsis</a></span></dt>
|
||||
<dt><span class="section"><a href="traits.html#boost_integer.traits.description">Description</a></span></dt>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<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">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
|
||||
<link rel="home" href="index.html" title="Boost.Integer">
|
||||
<link rel="next" href="boost_integer/traits.html" title="Integer Traits">
|
||||
</head>
|
||||
@ -50,7 +50,7 @@
|
||||
</div>
|
||||
<div class="toc">
|
||||
<p><b>Table of Contents</b></p>
|
||||
<dl class="toc">
|
||||
<dl>
|
||||
<dt><span class="section"><a href="index.html#boost_integer.overview">Overview</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_integer/traits.html">Integer Traits</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_integer/integer.html">Integer Type Selection</a></span></dt>
|
||||
@ -219,7 +219,7 @@
|
||||
</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="left"><p><small>Last revised: March 28, 2017 at 17:56:42 GMT</small></p></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
|
@ -1,28 +0,0 @@
|
||||
# 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*\>
|
942
doc/integer.qbk
942
doc/integer.qbk
File diff suppressed because it is too large
Load Diff
@ -1,62 +0,0 @@
|
||||
// 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]
|
||||
*/
|
@ -1,41 +0,0 @@
|
||||
// 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]
|
||||
*/
|
@ -1,69 +0,0 @@
|
||||
// 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]
|
||||
|
||||
*/
|
@ -1,73 +0,0 @@
|
||||
// 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]
|
||||
*/
|
@ -1,55 +0,0 @@
|
||||
// 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
|
||||
|
@ -1,251 +0,0 @@
|
||||
// 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]
|
||||
|
||||
*/
|
@ -1,33 +0,0 @@
|
||||
# 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 ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -6,9 +6,6 @@
|
||||
|
||||
// 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)
|
||||
// 01 Apr 01 Modified to use new <boost/limits.hpp> header. (John Maddock)
|
||||
@ -51,7 +48,6 @@ namespace boost
|
||||
typedef fast type;
|
||||
}; // imps may specialize
|
||||
|
||||
//! \cond DETAIL
|
||||
namespace detail{
|
||||
|
||||
// convert category to type
|
||||
@ -95,7 +91,8 @@ namespace boost
|
||||
template <> struct exact_signed_base_helper<sizeof(int)* CHAR_BIT> { typedef int exact; };
|
||||
template <> struct exact_unsigned_base_helper<sizeof(unsigned int)* CHAR_BIT> { typedef unsigned int exact; };
|
||||
#endif
|
||||
#if ULONG_MAX != UINT_MAX
|
||||
#if ULONG_MAX != UINT_MAX && ( !defined __TI_COMPILER_VERSION__ || \
|
||||
( __TI_COMPILER_VERSION__ >= 7000000 && !defined __TI_40BIT_LONG__ ) )
|
||||
template <> struct exact_signed_base_helper<sizeof(long)* CHAR_BIT> { typedef long exact; };
|
||||
template <> struct exact_unsigned_base_helper<sizeof(unsigned long)* CHAR_BIT> { typedef unsigned long exact; };
|
||||
#endif
|
||||
@ -108,8 +105,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 ---------------------------//
|
||||
|
||||
@ -170,7 +167,7 @@ namespace boost
|
||||
// integer templates specifying extreme value ----------------------------//
|
||||
|
||||
// signed
|
||||
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
|
||||
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
|
||||
template< boost::long_long_type MaxValue > // maximum value to require support
|
||||
#else
|
||||
template< long MaxValue > // maximum value to require support
|
||||
@ -179,7 +176,7 @@ namespace boost
|
||||
{
|
||||
typedef typename boost::detail::int_least_helper
|
||||
<
|
||||
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
|
||||
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
|
||||
(MaxValue <= ::boost::integer_traits<boost::long_long_type>::const_max) +
|
||||
#else
|
||||
1 +
|
||||
@ -192,7 +189,7 @@ namespace boost
|
||||
typedef typename int_fast_t<least>::type fast;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
|
||||
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
|
||||
template< boost::long_long_type MinValue > // minimum value to require support
|
||||
#else
|
||||
template< long MinValue > // minimum value to require support
|
||||
@ -201,7 +198,7 @@ namespace boost
|
||||
{
|
||||
typedef typename boost::detail::int_least_helper
|
||||
<
|
||||
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
|
||||
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
|
||||
(MinValue >= ::boost::integer_traits<boost::long_long_type>::const_min) +
|
||||
#else
|
||||
1 +
|
||||
@ -259,6 +256,7 @@ namespace boost
|
||||
typedef typename int_fast_t<least>::type fast;
|
||||
};
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_INTEGER_HPP
|
||||
|
@ -5,9 +5,7 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//! \file
|
||||
//! \brief Include both GCD and LCM.
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_INTEGER_COMMON_FACTOR_HPP
|
||||
#define BOOST_INTEGER_COMMON_FACTOR_HPP
|
||||
|
@ -5,25 +5,21 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//! \file
|
||||
//! \brief Evaluate Greatest Common Divisor and Least Common Multiple at compile-time.
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_INTEGER_COMMON_FACTOR_CT_HPP
|
||||
#define BOOST_INTEGER_COMMON_FACTOR_CT_HPP
|
||||
|
||||
#include <boost/integer_fwd.hpp> // Include for declaration of static_gcd_type and static_gcd.
|
||||
#include <boost/integer_fwd.hpp> // self include
|
||||
#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
|
||||
@ -75,7 +71,7 @@ namespace detail
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
//! \endcond // DETAIL
|
||||
|
||||
|
||||
// Compile-time greatest common divisor evaluator class declaration --------//
|
||||
|
||||
|
@ -4,56 +4,51 @@
|
||||
// use, modify, sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided "as is"
|
||||
// without express or implied warranty, and with no claim as to its suitability
|
||||
// for any purpose.
|
||||
// for any purpose.
|
||||
|
||||
// boostinspect:nolicense (don't complain about the lack of a Boost license)
|
||||
// (Paul Moore hasn't been in contact for years, so there's no way to change the
|
||||
// license.)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//! \file
|
||||
//! \brief Evaluate Least Common Multiple at compile-time.
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_INTEGER_COMMON_FACTOR_RT_HPP
|
||||
#define BOOST_INTEGER_COMMON_FACTOR_RT_HPP
|
||||
|
||||
#include <boost/integer_fwd.hpp> // self include
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_NESTED_TEMPLATE, etc.
|
||||
#include <boost/limits.hpp> // for std::numeric_limits
|
||||
#include <climits> // for CHAR_MIN
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <boost/integer_fwd.hpp> // Include for declarations of gcd_evaluator and lcm_evaluator.
|
||||
|
||||
#include <climits> // for CHAR_MIN
|
||||
#ifndef BOOST_NO_CXX11_NOEXCEPT
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127 4244) // Conditional expression is constant
|
||||
#endif
|
||||
|
||||
// Warning: this is from 1.58 in namespace boost::integer and no longer in namespace boost::math.
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace integer
|
||||
{
|
||||
// Forward declarations copied from <boost/math/common_factor_rt.hpp> at 1.58 -----//
|
||||
|
||||
#define BOOST_INT_NOEXCEPT(T) BOOST_NOEXCEPT_IF(boost::is_arithmetic<T>::value)
|
||||
|
||||
// Forward declarations for function templates -----------------------------//
|
||||
|
||||
template < typename IntegerType >
|
||||
IntegerType gcd( IntegerType const &a, IntegerType const &b );
|
||||
BOOST_CXX14_CONSTEXPR IntegerType gcd( IntegerType const &a, IntegerType const &b )BOOST_INT_NOEXCEPT(IntegerType);
|
||||
|
||||
template < typename IntegerType >
|
||||
IntegerType lcm( IntegerType const &a, IntegerType const &b );
|
||||
BOOST_CXX14_CONSTEXPR IntegerType lcm( IntegerType const &a, IntegerType const &b )BOOST_INT_NOEXCEPT(IntegerType);
|
||||
|
||||
|
||||
// Greatest common divisor evaluator class declaration ---------------------//
|
||||
|
||||
template < typename IntegerType >
|
||||
class gcd_evaluator;
|
||||
|
||||
template < typename IntegerType >
|
||||
class lcm_evaluator;
|
||||
|
||||
template < typename IntegerType >
|
||||
class gcd_evaluator
|
||||
{
|
||||
@ -62,8 +57,8 @@ public:
|
||||
typedef IntegerType result_type, first_argument_type, second_argument_type;
|
||||
|
||||
// Function object interface
|
||||
result_type operator ()( first_argument_type const &a,
|
||||
second_argument_type const &b ) const;
|
||||
BOOST_CXX14_CONSTEXPR result_type operator ()( first_argument_type const &a,
|
||||
second_argument_type const &b )const BOOST_INT_NOEXCEPT(IntegerType) ;
|
||||
|
||||
}; // boost::integer::gcd_evaluator
|
||||
|
||||
@ -78,25 +73,24 @@ public:
|
||||
typedef IntegerType result_type, first_argument_type, second_argument_type;
|
||||
|
||||
// Function object interface
|
||||
result_type operator ()( first_argument_type const &a,
|
||||
second_argument_type const &b ) const;
|
||||
BOOST_CXX14_CONSTEXPR result_type operator ()( first_argument_type const &a,
|
||||
second_argument_type const &b )const BOOST_INT_NOEXCEPT(IntegerType) ;
|
||||
|
||||
}; // boost::integer::lcm_evaluator
|
||||
|
||||
|
||||
// Implementation details --------------------------------------------------//
|
||||
//! \cond DETAIL
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// Greatest common divisor for rings (including unsigned integers)
|
||||
template < typename RingType >
|
||||
RingType
|
||||
BOOST_CXX14_CONSTEXPR RingType
|
||||
gcd_euclidean
|
||||
(
|
||||
RingType a,
|
||||
RingType b
|
||||
)
|
||||
)BOOST_INT_NOEXCEPT(RingType)
|
||||
{
|
||||
// Avoid repeated construction
|
||||
#ifndef __BORLANDC__
|
||||
@ -121,12 +115,12 @@ namespace detail
|
||||
// Greatest common divisor for (signed) integers
|
||||
template < typename IntegerType >
|
||||
inline
|
||||
IntegerType
|
||||
BOOST_CXX14_CONSTEXPR IntegerType
|
||||
gcd_integer
|
||||
(
|
||||
IntegerType const & a,
|
||||
IntegerType const & b
|
||||
)
|
||||
)BOOST_INT_NOEXCEPT(IntegerType)
|
||||
{
|
||||
// Avoid repeated construction
|
||||
IntegerType const zero = static_cast<IntegerType>( 0 );
|
||||
@ -137,12 +131,12 @@ namespace detail
|
||||
|
||||
// Greatest common divisor for unsigned binary integers
|
||||
template < typename BuiltInUnsigned >
|
||||
BuiltInUnsigned
|
||||
BOOST_CXX14_CONSTEXPR BuiltInUnsigned
|
||||
gcd_binary
|
||||
(
|
||||
BuiltInUnsigned u,
|
||||
BuiltInUnsigned v
|
||||
)
|
||||
)BOOST_INT_NOEXCEPT(BuiltInUnsigned)
|
||||
{
|
||||
if ( u && v )
|
||||
{
|
||||
@ -201,12 +195,12 @@ namespace detail
|
||||
// Least common multiple for rings (including unsigned integers)
|
||||
template < typename RingType >
|
||||
inline
|
||||
RingType
|
||||
BOOST_CXX14_CONSTEXPR RingType
|
||||
lcm_euclidean
|
||||
(
|
||||
RingType const & a,
|
||||
RingType const & b
|
||||
)
|
||||
)BOOST_INT_NOEXCEPT(RingType)
|
||||
{
|
||||
RingType const zero = static_cast<RingType>( 0 );
|
||||
RingType const temp = gcd_euclidean( a, b );
|
||||
@ -216,13 +210,13 @@ namespace detail
|
||||
|
||||
// Least common multiple for (signed) integers
|
||||
template < typename IntegerType >
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
IntegerType
|
||||
lcm_integer
|
||||
(
|
||||
IntegerType const & a,
|
||||
IntegerType const & b
|
||||
)
|
||||
)BOOST_INT_NOEXCEPT(IntegerType)
|
||||
{
|
||||
// Avoid repeated construction
|
||||
IntegerType const zero = static_cast<IntegerType>( 0 );
|
||||
@ -236,7 +230,7 @@ namespace detail
|
||||
template < typename T, bool IsSpecialized, bool IsSigned >
|
||||
struct gcd_optimal_evaluator_helper_t
|
||||
{
|
||||
T operator ()( T const &a, T const &b )
|
||||
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
|
||||
{
|
||||
return gcd_euclidean( a, b );
|
||||
}
|
||||
@ -245,7 +239,7 @@ namespace detail
|
||||
template < typename T >
|
||||
struct gcd_optimal_evaluator_helper_t< T, true, true >
|
||||
{
|
||||
T operator ()( T const &a, T const &b )
|
||||
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
|
||||
{
|
||||
return gcd_integer( a, b );
|
||||
}
|
||||
@ -254,7 +248,7 @@ namespace detail
|
||||
template < typename T >
|
||||
struct gcd_optimal_evaluator
|
||||
{
|
||||
T operator ()( T const &a, T const &b )
|
||||
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
|
||||
{
|
||||
typedef ::std::numeric_limits<T> limits_type;
|
||||
|
||||
@ -270,7 +264,7 @@ namespace detail
|
||||
template < typename T >
|
||||
struct gcd_optimal_evaluator
|
||||
{
|
||||
T operator ()( T const &a, T const &b )
|
||||
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
|
||||
{
|
||||
return gcd_integer( a, b );
|
||||
}
|
||||
@ -280,7 +274,7 @@ namespace detail
|
||||
// Specialize for the built-in integers
|
||||
#define BOOST_PRIVATE_GCD_UF( Ut ) \
|
||||
template < > struct gcd_optimal_evaluator<Ut> \
|
||||
{ Ut operator ()( Ut a, Ut b ) const { return gcd_binary( a, b ); } }
|
||||
{ BOOST_CXX14_CONSTEXPR Ut operator ()( Ut a, Ut b ) const BOOST_INT_NOEXCEPT(Ut) { return gcd_binary( a, b ); } }
|
||||
|
||||
BOOST_PRIVATE_GCD_UF( unsigned char );
|
||||
BOOST_PRIVATE_GCD_UF( unsigned short );
|
||||
@ -301,7 +295,7 @@ namespace detail
|
||||
|
||||
#define BOOST_PRIVATE_GCD_SF( St, Ut ) \
|
||||
template < > struct gcd_optimal_evaluator<St> \
|
||||
{ St operator ()( St a, St b ) const { Ut const a_abs = \
|
||||
{ BOOST_CXX14_CONSTEXPR St operator ()( St a, St b ) const BOOST_INT_NOEXCEPT(St) { Ut const a_abs = \
|
||||
static_cast<Ut>( a < 0 ? -a : +a ), b_abs = static_cast<Ut>( \
|
||||
b < 0 ? -b : +b ); return static_cast<St>( \
|
||||
gcd_optimal_evaluator<Ut>()(a_abs, b_abs) ); } }
|
||||
@ -327,7 +321,7 @@ namespace detail
|
||||
template < typename T, bool IsSpecialized, bool IsSigned >
|
||||
struct lcm_optimal_evaluator_helper_t
|
||||
{
|
||||
T operator ()( T const &a, T const &b )
|
||||
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
|
||||
{
|
||||
return lcm_euclidean( a, b );
|
||||
}
|
||||
@ -336,7 +330,7 @@ namespace detail
|
||||
template < typename T >
|
||||
struct lcm_optimal_evaluator_helper_t< T, true, true >
|
||||
{
|
||||
T operator ()( T const &a, T const &b )
|
||||
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
|
||||
{
|
||||
return lcm_integer( a, b );
|
||||
}
|
||||
@ -345,7 +339,7 @@ namespace detail
|
||||
template < typename T >
|
||||
struct lcm_optimal_evaluator
|
||||
{
|
||||
T operator ()( T const &a, T const &b )
|
||||
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
|
||||
{
|
||||
typedef ::std::numeric_limits<T> limits_type;
|
||||
|
||||
@ -361,7 +355,7 @@ namespace detail
|
||||
template < typename T >
|
||||
struct lcm_optimal_evaluator
|
||||
{
|
||||
T operator ()( T const &a, T const &b )
|
||||
BOOST_CXX14_CONSTEXPR T operator ()( T const &a, T const &b )BOOST_INT_NOEXCEPT(T)
|
||||
{
|
||||
return lcm_integer( a, b );
|
||||
}
|
||||
@ -370,13 +364,13 @@ namespace detail
|
||||
|
||||
// Functions to find the GCD or LCM in the best way
|
||||
template < typename T >
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
T
|
||||
gcd_optimal
|
||||
(
|
||||
T const & a,
|
||||
T const & b
|
||||
)
|
||||
)BOOST_INT_NOEXCEPT(T)
|
||||
{
|
||||
gcd_optimal_evaluator<T> solver;
|
||||
|
||||
@ -384,13 +378,13 @@ namespace detail
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
T
|
||||
lcm_optimal
|
||||
(
|
||||
T const & a,
|
||||
T const & b
|
||||
)
|
||||
)BOOST_INT_NOEXCEPT(T)
|
||||
{
|
||||
lcm_optimal_evaluator<T> solver;
|
||||
|
||||
@ -398,79 +392,62 @@ namespace detail
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
//! \endcond // DETAIL
|
||||
|
||||
// Greatest common divisor operator() evaluator member function definition ------------//
|
||||
//! Evaluation operator() for Greatest Common Divisor (GCD) of two arguments.
|
||||
//! \tparam IntegerType must be an integral constant http://en.cppreference.com/w/cpp/types/integral_constant
|
||||
//! \param a first_argument_type
|
||||
//! \param b second_argument_type
|
||||
|
||||
// Greatest common divisor evaluator member function definition ------------//
|
||||
|
||||
template < typename IntegerType >
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
typename gcd_evaluator<IntegerType>::result_type
|
||||
gcd_evaluator<IntegerType>::operator ()
|
||||
(
|
||||
first_argument_type const & a,
|
||||
second_argument_type const & b
|
||||
) const
|
||||
) const BOOST_INT_NOEXCEPT(IntegerType)
|
||||
{
|
||||
return detail::gcd_optimal( a, b );
|
||||
}
|
||||
|
||||
|
||||
// Least common multiple evaluator member function definition --------------//
|
||||
//! Evaluates Least Common Multiplier of two arguments.
|
||||
//! \tparam IntegerType must be an integral constant http://en.cppreference.com/w/cpp/types/integral_constant
|
||||
//! \tparam IntegerType must be an integral constant http://en.cppreference.com/w/cpp/types/integral_constant
|
||||
//! \param a first_argument_type
|
||||
//! \param b second_argument_type
|
||||
|
||||
template < typename IntegerType >
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
typename lcm_evaluator<IntegerType>::result_type
|
||||
lcm_evaluator<IntegerType>::operator ()
|
||||
(
|
||||
first_argument_type const & a,
|
||||
second_argument_type const & b
|
||||
) const
|
||||
) const BOOST_INT_NOEXCEPT(IntegerType)
|
||||
{
|
||||
return detail::lcm_optimal( a, b );
|
||||
}
|
||||
|
||||
|
||||
// Greatest common divisor and least common multiple function definitions --//
|
||||
//! Function for Greatest Common Divisor (GCD) of two arguments.
|
||||
//! \tparam IntegerType must be an integral constant http://en.cppreference.com/w/cpp/types/integral_constant
|
||||
//! \param a first_argument_type
|
||||
//! \param b second_argument_type
|
||||
|
||||
template < typename IntegerType >
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
IntegerType
|
||||
gcd
|
||||
(
|
||||
IntegerType const & a,
|
||||
IntegerType const & b
|
||||
)
|
||||
) BOOST_INT_NOEXCEPT(IntegerType)
|
||||
{
|
||||
gcd_evaluator<IntegerType> solver;
|
||||
|
||||
return solver( a, b );
|
||||
}
|
||||
|
||||
//! Function for Least Common Multiplier (LCM) of two arguments.
|
||||
//! \tparam IntegerType must be an integral constant http://en.cppreference.com/w/cpp/types/integral_constant
|
||||
//! \param a first_argument_type
|
||||
//! \param b second_argument_type
|
||||
|
||||
template < typename IntegerType >
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
IntegerType
|
||||
lcm
|
||||
(
|
||||
IntegerType const & a,
|
||||
IntegerType const & b
|
||||
)
|
||||
) BOOST_INT_NOEXCEPT(IntegerType)
|
||||
{
|
||||
lcm_evaluator<IntegerType> solver;
|
||||
|
||||
|
@ -1,18 +1,15 @@
|
||||
// -----------------------------------------------------------
|
||||
// integer_log2.hpp
|
||||
//
|
||||
// Gives the integer part of the logarithm, in base 2, of a
|
||||
// given number. Behavior is undefined if the argument is <= 0.
|
||||
//
|
||||
// Copyright (c) 2003-2004, 2008 Gennaro Prota
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
//! \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
|
||||
@ -27,8 +24,6 @@
|
||||
|
||||
|
||||
namespace boost {
|
||||
|
||||
//! \cond DETAIL
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
@ -51,6 +46,7 @@ namespace boost {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// helper to find the maximum power of two
|
||||
// less than p (more involved than necessary,
|
||||
// to avoid PTS)
|
||||
@ -86,8 +82,9 @@ namespace boost {
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
} // detail
|
||||
//! \endcond // DETAIL
|
||||
|
||||
|
||||
// ---------
|
||||
// integer_log2
|
||||
@ -107,6 +104,9 @@ namespace boost {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // BOOST_INTEGER_INTEGER_LOG2_HPP include guard
|
||||
|
||||
|
||||
#endif // include guard
|
||||
|
@ -5,10 +5,7 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
//! \file
|
||||
//! \brief Compile-time integer mask evaluation.
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_INTEGER_INTEGER_MASK_HPP
|
||||
#define BOOST_INTEGER_INTEGER_MASK_HPP
|
||||
@ -38,6 +35,7 @@
|
||||
namespace boost
|
||||
{
|
||||
|
||||
|
||||
// Specified single-bit mask class declaration -----------------------------//
|
||||
// (Lowest bit starts counting at 0.)
|
||||
|
||||
@ -65,7 +63,7 @@ struct low_bits_mask_t
|
||||
typedef typename uint_t<Bits>::least least;
|
||||
typedef typename uint_t<Bits>::fast fast;
|
||||
|
||||
BOOST_STATIC_CONSTANT( least, sig_bits = (~( ~(least( 0u )) << Bits )) );
|
||||
BOOST_STATIC_CONSTANT( least, sig_bits = (~(least(~(least( 0u ))) << Bits )) );
|
||||
BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) );
|
||||
|
||||
BOOST_STATIC_CONSTANT( std::size_t, bit_count = Bits );
|
||||
|
@ -10,11 +10,6 @@
|
||||
//
|
||||
// ---------------------------------------------------
|
||||
// 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.
|
||||
|
||||
// ------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
@ -25,8 +20,6 @@
|
||||
|
||||
namespace boost {
|
||||
|
||||
//! \cond DETAIL
|
||||
|
||||
namespace detail {
|
||||
|
||||
namespace static_log2_impl {
|
||||
@ -106,7 +99,8 @@ namespace boost {
|
||||
|
||||
}
|
||||
} // detail
|
||||
//! \endcond // DETAIL
|
||||
|
||||
|
||||
|
||||
// --------------------------------------
|
||||
// static_log2<x>
|
||||
@ -126,7 +120,7 @@ namespace boost {
|
||||
template <>
|
||||
struct static_log2<0> { };
|
||||
|
||||
} // namespace boost
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -5,9 +5,7 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//! \file
|
||||
//! \brief Compile-time evaluation of extrema: minimum or maximum of two values, signed or unsigned.
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_INTEGER_STATIC_MIN_MAX_HPP
|
||||
#define BOOST_INTEGER_STATIC_MIN_MAX_HPP
|
||||
|
@ -5,8 +5,6 @@
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// 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
|
||||
@ -18,6 +16,7 @@
|
||||
#include <boost/limits.hpp> // for std::numeric_limits
|
||||
#include <boost/cstdint.hpp> // For intmax_t
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
@ -159,9 +158,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
|
||||
@ -183,7 +182,7 @@ template < typename IntegerType >
|
||||
template < typename IntegerType >
|
||||
class lcm_evaluator;
|
||||
|
||||
] // namespace integer
|
||||
} // namespace integer
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
@ -8,15 +8,10 @@
|
||||
* $Id$
|
||||
*
|
||||
* Idea by Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers
|
||||
|
||||
*/
|
||||
|
||||
// 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
|
||||
#define BOOST_INTEGER_TRAITS_HPP
|
||||
@ -52,7 +47,6 @@ 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
|
||||
@ -76,7 +70,6 @@ const T integer_traits_base<T, min_val, max_val>::const_max;
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
//! \endcond // DETAIL
|
||||
|
||||
template<>
|
||||
class integer_traits<bool>
|
||||
|
@ -19,11 +19,13 @@ test-suite integer
|
||||
[ compile static_log2_include_test.cpp ]
|
||||
[ compile static_min_max_include_test.cpp ]
|
||||
[ compile integer_fwd_include_test.cpp ]
|
||||
[ compile gcd_constexpr14_test.cpp ]
|
||||
[ compile-fail fail_int_exact.cpp ]
|
||||
[ compile-fail fail_int_fast.cpp ]
|
||||
[ compile-fail fail_int_least.cpp ]
|
||||
[ compile-fail fail_uint_exact.cpp ]
|
||||
[ compile-fail fail_uint_fast.cpp ]
|
||||
[ compile-fail fail_uint_least.cpp ]
|
||||
[ compile-fail fail_uint_65.cpp ]
|
||||
[ run common_factor_test.cpp ]
|
||||
;
|
||||
|
13
test/fail_uint_65.cpp
Normal file
13
test/fail_uint_65.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright John Maddock 2012.
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/integer.hpp>
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << std::numeric_limits<boost::uint_t<65>::least>::digits;
|
||||
return 0;
|
||||
}
|
42
test/gcd_constexpr14_test.cpp
Normal file
42
test/gcd_constexpr14_test.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
// (C) Copyright John Maddock 2017.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/integer/common_factor.hpp>
|
||||
|
||||
#ifndef BOOST_NO_CXX14_CONSTEXPR
|
||||
|
||||
void test_constexpr()
|
||||
{
|
||||
constexpr const boost::int64_t i = 347 * 463 * 727;
|
||||
constexpr const boost::int64_t j = 191 * 347 * 281;
|
||||
|
||||
constexpr const boost::int64_t k = boost::integer::gcd(i, j);
|
||||
constexpr const boost::int64_t l = boost::integer::lcm(i, j);
|
||||
|
||||
static_assert(k == 347, "Expected result not found in constexpr gcd.");
|
||||
static_assert(l == 6268802158037, "Expected result not found in constexpr lcm.");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX11_NOEXCEPT
|
||||
|
||||
void test_noexcept()
|
||||
{
|
||||
static_assert(noexcept(boost::integer::gcd(static_cast<unsigned char>(2), static_cast<unsigned char>(4))), "Expected a noexcept function.");
|
||||
static_assert(noexcept(boost::integer::gcd(static_cast<char>(2), static_cast<char>(4))), "Expected a noexcept function.");
|
||||
static_assert(noexcept(boost::integer::gcd(static_cast<signed char>(2), static_cast<signed char>(4))), "Expected a noexcept function.");
|
||||
static_assert(noexcept(boost::integer::gcd(static_cast<short>(2), static_cast<short>(4))), "Expected a noexcept function.");
|
||||
static_assert(noexcept(boost::integer::gcd(static_cast<unsigned short>(2), static_cast<unsigned short>(4))), "Expected a noexcept function.");
|
||||
static_assert(noexcept(boost::integer::gcd(static_cast<int>(2), static_cast<int>(4))), "Expected a noexcept function.");
|
||||
static_assert(noexcept(boost::integer::gcd(static_cast<unsigned int>(2), static_cast<unsigned int>(4))), "Expected a noexcept function.");
|
||||
static_assert(noexcept(boost::integer::gcd(static_cast<long>(2), static_cast<long>(4))), "Expected a noexcept function.");
|
||||
static_assert(noexcept(boost::integer::gcd(static_cast<unsigned long>(2), static_cast<unsigned long>(4))), "Expected a noexcept function.");
|
||||
static_assert(noexcept(boost::integer::gcd(static_cast<long long>(2), static_cast<long long>(4))), "Expected a noexcept function.");
|
||||
static_assert(noexcept(boost::integer::gcd(static_cast<unsigned long long>(2), static_cast<unsigned long long>(4))), "Expected a noexcept function.");
|
||||
}
|
||||
|
||||
#endif
|
@ -18,6 +18,7 @@
|
||||
#include <boost/detail/lightweight_test.hpp> // for main, BOOST_TEST
|
||||
#include <boost/integer.hpp> // for boost::int_t, boost::uint_t
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/bool.hpp> // for mpl::true_ and false_
|
||||
|
||||
#include <climits> // for ULONG_MAX, LONG_MAX, LONG_MIN
|
||||
#include <iostream> // for std::cout (std::endl indirectly)
|
||||
@ -69,7 +70,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 ::exact member.
|
||||
// Nothing to do, type does not have an ::extact member.
|
||||
}
|
||||
|
||||
template <int Bits>
|
||||
|
Reference in New Issue
Block a user