Compare commits

...

11 Commits

Author SHA1 Message Date
39d9701857 Enable one more noexcept test 2017-03-28 19:30:48 +01:00
45cc025bbd Merge branch 'bugfix/bitwise-not-and-gcc6' of https://github.com/Flast/boost-integer into cpp14 2017-03-28 19:28:51 +01:00
13b36d8432 Add tests for C++14 support. 2017-03-28 19:06:13 +01:00
a52bae3639 Improve C++14 support:
* Make functions constexpr.
* Make functions noexcept where appropriate.
* Add test case for the above.
2017-03-28 18:57:50 +01:00
13b153c657 Add, and update, documentation build targets. 2016-10-07 23:07:34 -05:00
89cec128bd Fix compile error on GCC6 or later.
Bitwise not yields integral promotion and to be signed type.
2016-07-30 16:12:07 +09:00
175a1caa58 Placed GCD and LCM typdefs and declarations in integer_fwd.hpp inside namespace boost::integer (was in boost::math) and checked that expected tests pass (and expected fails fail).
(Major update to Boost.Integer docs available for review at https://dl.dropboxusercontent.com/u/43940943/modular-boost/libs/integer/index.html
on branch doc-revision).
2015-01-29 11:53:02 +00:00
1ff7278d5f Added compile fail test for uint_t<65>. related to #6169. 2015-01-25 17:26:09 +01:00
a12b96c011 manage with #4881. 2015-01-25 17:11:04 +01:00
7ffb75bb43 manage with #6694 Boost.Integer part. 2015-01-25 17:03:09 +01:00
83feb20e51 Missing #include
Test case uses mpl:: types without including the needed header - exposed by ongoing type traits rewrite.
2015-01-23 19:05:59 +00:00
18 changed files with 162 additions and 80 deletions

View File

@ -53,4 +53,8 @@ boostbook standalone
install pdfinstall : standalone/<format>pdf : <location>. <install-type>PDF ; install pdfinstall : standalone/<format>pdf : <location>. <install-type>PDF ;
explicit pdfinstall ; explicit pdfinstall ;
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : standalone ;
explicit boostrelease ;

View File

@ -24,9 +24,9 @@ programming problems.
class lcm_evaluator; class lcm_evaluator;
template < typename IntegerType > template < typename IntegerType >
IntegerType gcd( IntegerType const &a, IntegerType const &b ); constexpr IntegerType gcd( IntegerType const &a, IntegerType const &b );
template < typename IntegerType > 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; typedef ``['see-below]`` static_gcd_type;
@ -54,8 +54,9 @@ programming problems.
typedef IntegerType second_argument_type; typedef IntegerType second_argument_type;
// Function object interface // Function object interface
result_type operator ()( first_argument_type const &a, constexpr result_type operator ()(
second_argument_type const &b ) const; first_argument_type const &a,
second_argument_type const &b ) const;
}; };
The boost::math::gcd_evaluator class template defines a function object 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 of its greatest common divisors, then the type should specialize on the
gcd_evaluator class template. 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] [endsect]
[section LCM Function Object] [section LCM Function Object]
@ -86,8 +90,9 @@ gcd_evaluator class template.
typedef IntegerType second_argument_type; typedef IntegerType second_argument_type;
// Function object interface // Function object interface
result_type operator ()( first_argument_type const &a, constexpr result_type operator ()(
second_argument_type const &b ) const; first_argument_type const &a,
second_argument_type const &b ) const;
}; };
The boost::math::lcm_evaluator class template defines a function object 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 evaluations of its least common multiples, then the type should
specialize on the lcm_evaluator class template. 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] [endsect]
[section:run_time Run-time GCD & LCM Determination] [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>] [*Header: ] [@../../../../boost/math/common_factor_rt.hpp <boost/math/common_factor_rt.hpp>]
template < typename IntegerType > 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 > 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 The boost::math::gcd function template returns the greatest common
(nonnegative) divisor of the two integers passed to it. (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 templates use an object of the corresponding version of the
gcd_evaluator and lcm_evaluator class templates, respectively. 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] [endsect]
[section:compile_time Compile time GCD and LCM determination] [section:compile_time Compile time GCD and LCM determination]

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Removed from library: Standard Integer Types</title> <title>Removed from library: Standard Integer Types</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> <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="home" href="../index.html" title="Boost.Integer">
<link rel="up" href="../index.html" title="Boost.Integer"> <link rel="up" href="../index.html" title="Boost.Integer">
<link rel="prev" href="history.html" title="History"> <link rel="prev" href="history.html" title="History">

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>History</title> <title>History</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> <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="home" href="../index.html" title="Boost.Integer">
<link rel="up" 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="prev" href="minmax.html" title="Compile time min/max calculation">

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Integer Type Selection</title> <title>Integer Type Selection</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> <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="home" href="../index.html" title="Boost.Integer">
<link rel="up" 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="prev" href="traits.html" title="Integer Traits">
@ -26,7 +26,7 @@
<div class="titlepage"><div><div><h2 class="title" style="clear: both"> <div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_integer.integer"></a><a class="link" href="integer.html" title="Integer Type Selection">Integer Type Selection</a> <a name="boost_integer.integer"></a><a class="link" href="integer.html" title="Integer Type Selection">Integer Type Selection</a>
</h2></div></div></div> </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.synopsis">Synopsis</a></span></dt>
<dt><span class="section"><a href="integer.html#boost_integer.integer.easiest">Easiest-to-Manipulate <dt><span class="section"><a href="integer.html#boost_integer.integer.easiest">Easiest-to-Manipulate
Types</a></span></dt> Types</a></span></dt>

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Compile Time log2 Calculation</title> <title>Compile Time log2 Calculation</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> <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="home" href="../index.html" title="Boost.Integer">
<link rel="up" 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="prev" href="mask.html" title="Integer Masks">
@ -26,7 +26,7 @@
<div class="titlepage"><div><div><h2 class="title" style="clear: both"> <div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_integer.log2"></a><a class="link" href="log2.html" title="Compile Time log2 Calculation">Compile Time log2 Calculation</a> <a name="boost_integer.log2"></a><a class="link" href="log2.html" title="Compile Time log2 Calculation">Compile Time log2 Calculation</a>
</h2></div></div></div> </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.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.usage">Usage</a></span></dt>
<dt><span class="section"><a href="log2.html#boost_integer.log2.demonstration_program">Demonstration <dt><span class="section"><a href="log2.html#boost_integer.log2.demonstration_program">Demonstration

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Integer Masks</title> <title>Integer Masks</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> <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="home" href="../index.html" title="Boost.Integer">
<link rel="up" 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="prev" href="integer.html" title="Integer Type Selection">
@ -26,7 +26,7 @@
<div class="titlepage"><div><div><h2 class="title" style="clear: both"> <div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_integer.mask"></a><a class="link" href="mask.html" title="Integer Masks">Integer Masks</a> <a name="boost_integer.mask"></a><a class="link" href="mask.html" title="Integer Masks">Integer Masks</a>
</h2></div></div></div> </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.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.synopsis">Synopsis</a></span></dt>
<dt><span class="section"><a href="mask.html#boost_integer.mask.single_bit_mask_class_template">Single <dt><span class="section"><a href="mask.html#boost_integer.mask.single_bit_mask_class_template">Single

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Compile time min/max calculation</title> <title>Compile time min/max calculation</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> <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="home" href="../index.html" title="Boost.Integer">
<link rel="up" 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="prev" href="log2.html" title="Compile Time log2 Calculation">
@ -26,7 +26,7 @@
<div class="titlepage"><div><div><h2 class="title" style="clear: both"> <div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_integer.minmax"></a><a class="link" href="minmax.html" title="Compile time min/max calculation">Compile time min/max calculation</a> <a name="boost_integer.minmax"></a><a class="link" href="minmax.html" title="Compile time min/max calculation">Compile time min/max calculation</a>
</h2></div></div></div> </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.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.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.example">Example</a></span></dt>

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Integer Traits</title> <title>Integer Traits</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> <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="home" href="../index.html" title="Boost.Integer">
<link rel="up" 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="prev" href="../index.html" title="Boost.Integer">
@ -26,7 +26,7 @@
<div class="titlepage"><div><div><h2 class="title" style="clear: both"> <div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_integer.traits"></a><a class="link" href="traits.html" title="Integer Traits">Integer Traits</a> <a name="boost_integer.traits"></a><a class="link" href="traits.html" title="Integer Traits">Integer Traits</a>
</h2></div></div></div> </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.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.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.description">Description</a></span></dt>

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Boost.Integer</title> <title>Boost.Integer</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css"> <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="home" href="index.html" title="Boost.Integer">
<link rel="next" href="boost_integer/traits.html" title="Integer Traits"> <link rel="next" href="boost_integer/traits.html" title="Integer Traits">
</head> </head>
@ -50,7 +50,7 @@
</div> </div>
<div class="toc"> <div class="toc">
<p><b>Table of Contents</b></p> <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="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/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/integer.html">Integer Type Selection</a></span></dt>
@ -219,7 +219,7 @@
</div> </div>
</div> </div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <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> <td align="right"><div class="copyright-footer"></div></td>
</tr></table> </tr></table>
<hr> <hr>

View File

@ -91,7 +91,8 @@ namespace boost
template <> struct exact_signed_base_helper<sizeof(int)* CHAR_BIT> { typedef int exact; }; 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; }; template <> struct exact_unsigned_base_helper<sizeof(unsigned int)* CHAR_BIT> { typedef unsigned int exact; };
#endif #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_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; }; template <> struct exact_unsigned_base_helper<sizeof(unsigned long)* CHAR_BIT> { typedef unsigned long exact; };
#endif #endif
@ -166,7 +167,7 @@ namespace boost
// integer templates specifying extreme value ----------------------------// // integer templates specifying extreme value ----------------------------//
// signed // 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 template< boost::long_long_type MaxValue > // maximum value to require support
#else #else
template< long MaxValue > // maximum value to require support template< long MaxValue > // maximum value to require support
@ -175,7 +176,7 @@ namespace boost
{ {
typedef typename boost::detail::int_least_helper typedef typename boost::detail::int_least_helper
< <
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) #if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
(MaxValue <= ::boost::integer_traits<boost::long_long_type>::const_max) + (MaxValue <= ::boost::integer_traits<boost::long_long_type>::const_max) +
#else #else
1 + 1 +
@ -188,7 +189,7 @@ namespace boost
typedef typename int_fast_t<least>::type fast; 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 template< boost::long_long_type MinValue > // minimum value to require support
#else #else
template< long MinValue > // minimum value to require support template< long MinValue > // minimum value to require support
@ -197,7 +198,7 @@ namespace boost
{ {
typedef typename boost::detail::int_least_helper typedef typename boost::detail::int_least_helper
< <
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) #if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG)
(MinValue >= ::boost::integer_traits<boost::long_long_type>::const_min) + (MinValue >= ::boost::integer_traits<boost::long_long_type>::const_min) +
#else #else
1 + 1 +

View File

@ -22,6 +22,10 @@
#include <climits> // for CHAR_MIN #include <climits> // for CHAR_MIN
#include <boost/detail/workaround.hpp> #include <boost/detail/workaround.hpp>
#ifndef BOOST_NO_CXX11_NOEXCEPT
#include <boost/type_traits/is_arithmetic.hpp>
#endif
#ifdef BOOST_MSVC #ifdef BOOST_MSVC
#pragma warning(push) #pragma warning(push)
#pragma warning(disable:4127 4244) // Conditional expression is constant #pragma warning(disable:4127 4244) // Conditional expression is constant
@ -32,14 +36,15 @@ namespace boost
namespace integer namespace integer
{ {
#define BOOST_INT_NOEXCEPT(T) BOOST_NOEXCEPT_IF(boost::is_arithmetic<T>::value)
// Forward declarations for function templates -----------------------------// // Forward declarations for function templates -----------------------------//
template < typename IntegerType > 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 > 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 ---------------------// // Greatest common divisor evaluator class declaration ---------------------//
@ -52,8 +57,8 @@ public:
typedef IntegerType result_type, first_argument_type, second_argument_type; typedef IntegerType result_type, first_argument_type, second_argument_type;
// Function object interface // Function object interface
result_type operator ()( first_argument_type const &a, BOOST_CXX14_CONSTEXPR result_type operator ()( first_argument_type const &a,
second_argument_type const &b ) const; second_argument_type const &b )const BOOST_INT_NOEXCEPT(IntegerType) ;
}; // boost::integer::gcd_evaluator }; // boost::integer::gcd_evaluator
@ -68,8 +73,8 @@ public:
typedef IntegerType result_type, first_argument_type, second_argument_type; typedef IntegerType result_type, first_argument_type, second_argument_type;
// Function object interface // Function object interface
result_type operator ()( first_argument_type const &a, BOOST_CXX14_CONSTEXPR result_type operator ()( first_argument_type const &a,
second_argument_type const &b ) const; second_argument_type const &b )const BOOST_INT_NOEXCEPT(IntegerType) ;
}; // boost::integer::lcm_evaluator }; // boost::integer::lcm_evaluator
@ -80,12 +85,12 @@ namespace detail
{ {
// Greatest common divisor for rings (including unsigned integers) // Greatest common divisor for rings (including unsigned integers)
template < typename RingType > template < typename RingType >
RingType BOOST_CXX14_CONSTEXPR RingType
gcd_euclidean gcd_euclidean
( (
RingType a, RingType a,
RingType b RingType b
) )BOOST_INT_NOEXCEPT(RingType)
{ {
// Avoid repeated construction // Avoid repeated construction
#ifndef __BORLANDC__ #ifndef __BORLANDC__
@ -110,12 +115,12 @@ namespace detail
// Greatest common divisor for (signed) integers // Greatest common divisor for (signed) integers
template < typename IntegerType > template < typename IntegerType >
inline inline
IntegerType BOOST_CXX14_CONSTEXPR IntegerType
gcd_integer gcd_integer
( (
IntegerType const & a, IntegerType const & a,
IntegerType const & b IntegerType const & b
) )BOOST_INT_NOEXCEPT(IntegerType)
{ {
// Avoid repeated construction // Avoid repeated construction
IntegerType const zero = static_cast<IntegerType>( 0 ); IntegerType const zero = static_cast<IntegerType>( 0 );
@ -126,12 +131,12 @@ namespace detail
// Greatest common divisor for unsigned binary integers // Greatest common divisor for unsigned binary integers
template < typename BuiltInUnsigned > template < typename BuiltInUnsigned >
BuiltInUnsigned BOOST_CXX14_CONSTEXPR BuiltInUnsigned
gcd_binary gcd_binary
( (
BuiltInUnsigned u, BuiltInUnsigned u,
BuiltInUnsigned v BuiltInUnsigned v
) )BOOST_INT_NOEXCEPT(BuiltInUnsigned)
{ {
if ( u && v ) if ( u && v )
{ {
@ -190,12 +195,12 @@ namespace detail
// Least common multiple for rings (including unsigned integers) // Least common multiple for rings (including unsigned integers)
template < typename RingType > template < typename RingType >
inline inline
RingType BOOST_CXX14_CONSTEXPR RingType
lcm_euclidean lcm_euclidean
( (
RingType const & a, RingType const & a,
RingType const & b RingType const & b
) )BOOST_INT_NOEXCEPT(RingType)
{ {
RingType const zero = static_cast<RingType>( 0 ); RingType const zero = static_cast<RingType>( 0 );
RingType const temp = gcd_euclidean( a, b ); RingType const temp = gcd_euclidean( a, b );
@ -205,13 +210,13 @@ namespace detail
// Least common multiple for (signed) integers // Least common multiple for (signed) integers
template < typename IntegerType > template < typename IntegerType >
inline inline BOOST_CXX14_CONSTEXPR
IntegerType IntegerType
lcm_integer lcm_integer
( (
IntegerType const & a, IntegerType const & a,
IntegerType const & b IntegerType const & b
) )BOOST_INT_NOEXCEPT(IntegerType)
{ {
// Avoid repeated construction // Avoid repeated construction
IntegerType const zero = static_cast<IntegerType>( 0 ); IntegerType const zero = static_cast<IntegerType>( 0 );
@ -225,7 +230,7 @@ namespace detail
template < typename T, bool IsSpecialized, bool IsSigned > template < typename T, bool IsSpecialized, bool IsSigned >
struct gcd_optimal_evaluator_helper_t 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 ); return gcd_euclidean( a, b );
} }
@ -234,7 +239,7 @@ namespace detail
template < typename T > template < typename T >
struct gcd_optimal_evaluator_helper_t< T, true, true > 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 ); return gcd_integer( a, b );
} }
@ -243,7 +248,7 @@ namespace detail
template < typename T > template < typename T >
struct gcd_optimal_evaluator 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; typedef ::std::numeric_limits<T> limits_type;
@ -259,7 +264,7 @@ namespace detail
template < typename T > template < typename T >
struct gcd_optimal_evaluator 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 ); return gcd_integer( a, b );
} }
@ -269,7 +274,7 @@ namespace detail
// Specialize for the built-in integers // Specialize for the built-in integers
#define BOOST_PRIVATE_GCD_UF( Ut ) \ #define BOOST_PRIVATE_GCD_UF( Ut ) \
template < > struct gcd_optimal_evaluator<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 char );
BOOST_PRIVATE_GCD_UF( unsigned short ); BOOST_PRIVATE_GCD_UF( unsigned short );
@ -290,7 +295,7 @@ namespace detail
#define BOOST_PRIVATE_GCD_SF( St, Ut ) \ #define BOOST_PRIVATE_GCD_SF( St, Ut ) \
template < > struct gcd_optimal_evaluator<St> \ 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>( \ static_cast<Ut>( a < 0 ? -a : +a ), b_abs = static_cast<Ut>( \
b < 0 ? -b : +b ); return static_cast<St>( \ b < 0 ? -b : +b ); return static_cast<St>( \
gcd_optimal_evaluator<Ut>()(a_abs, b_abs) ); } } gcd_optimal_evaluator<Ut>()(a_abs, b_abs) ); } }
@ -316,7 +321,7 @@ namespace detail
template < typename T, bool IsSpecialized, bool IsSigned > template < typename T, bool IsSpecialized, bool IsSigned >
struct lcm_optimal_evaluator_helper_t 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 ); return lcm_euclidean( a, b );
} }
@ -325,7 +330,7 @@ namespace detail
template < typename T > template < typename T >
struct lcm_optimal_evaluator_helper_t< T, true, true > 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 ); return lcm_integer( a, b );
} }
@ -334,7 +339,7 @@ namespace detail
template < typename T > template < typename T >
struct lcm_optimal_evaluator 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; typedef ::std::numeric_limits<T> limits_type;
@ -350,7 +355,7 @@ namespace detail
template < typename T > template < typename T >
struct lcm_optimal_evaluator 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 ); return lcm_integer( a, b );
} }
@ -359,13 +364,13 @@ namespace detail
// Functions to find the GCD or LCM in the best way // Functions to find the GCD or LCM in the best way
template < typename T > template < typename T >
inline inline BOOST_CXX14_CONSTEXPR
T T
gcd_optimal gcd_optimal
( (
T const & a, T const & a,
T const & b T const & b
) )BOOST_INT_NOEXCEPT(T)
{ {
gcd_optimal_evaluator<T> solver; gcd_optimal_evaluator<T> solver;
@ -373,13 +378,13 @@ namespace detail
} }
template < typename T > template < typename T >
inline inline BOOST_CXX14_CONSTEXPR
T T
lcm_optimal lcm_optimal
( (
T const & a, T const & a,
T const & b T const & b
) )BOOST_INT_NOEXCEPT(T)
{ {
lcm_optimal_evaluator<T> solver; lcm_optimal_evaluator<T> solver;
@ -392,13 +397,13 @@ namespace detail
// Greatest common divisor evaluator member function definition ------------// // Greatest common divisor evaluator member function definition ------------//
template < typename IntegerType > template < typename IntegerType >
inline inline BOOST_CXX14_CONSTEXPR
typename gcd_evaluator<IntegerType>::result_type typename gcd_evaluator<IntegerType>::result_type
gcd_evaluator<IntegerType>::operator () gcd_evaluator<IntegerType>::operator ()
( (
first_argument_type const & a, first_argument_type const & a,
second_argument_type const & b second_argument_type const & b
) const ) const BOOST_INT_NOEXCEPT(IntegerType)
{ {
return detail::gcd_optimal( a, b ); return detail::gcd_optimal( a, b );
} }
@ -407,13 +412,13 @@ gcd_evaluator<IntegerType>::operator ()
// Least common multiple evaluator member function definition --------------// // Least common multiple evaluator member function definition --------------//
template < typename IntegerType > template < typename IntegerType >
inline inline BOOST_CXX14_CONSTEXPR
typename lcm_evaluator<IntegerType>::result_type typename lcm_evaluator<IntegerType>::result_type
lcm_evaluator<IntegerType>::operator () lcm_evaluator<IntegerType>::operator ()
( (
first_argument_type const & a, first_argument_type const & a,
second_argument_type const & b second_argument_type const & b
) const ) const BOOST_INT_NOEXCEPT(IntegerType)
{ {
return detail::lcm_optimal( a, b ); return detail::lcm_optimal( a, b );
} }
@ -422,13 +427,13 @@ lcm_evaluator<IntegerType>::operator ()
// Greatest common divisor and least common multiple function definitions --// // Greatest common divisor and least common multiple function definitions --//
template < typename IntegerType > template < typename IntegerType >
inline inline BOOST_CXX14_CONSTEXPR
IntegerType IntegerType
gcd gcd
( (
IntegerType const & a, IntegerType const & a,
IntegerType const & b IntegerType const & b
) ) BOOST_INT_NOEXCEPT(IntegerType)
{ {
gcd_evaluator<IntegerType> solver; gcd_evaluator<IntegerType> solver;
@ -436,13 +441,13 @@ gcd
} }
template < typename IntegerType > template < typename IntegerType >
inline inline BOOST_CXX14_CONSTEXPR
IntegerType IntegerType
lcm lcm
( (
IntegerType const & a, IntegerType const & a,
IntegerType const & b IntegerType const & b
) ) BOOST_INT_NOEXCEPT(IntegerType)
{ {
lcm_evaluator<IntegerType> solver; lcm_evaluator<IntegerType> solver;

View File

@ -63,7 +63,7 @@ struct low_bits_mask_t
typedef typename uint_t<Bits>::least least; typedef typename uint_t<Bits>::least least;
typedef typename uint_t<Bits>::fast fast; 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( fast, sig_bits_fast = fast(sig_bits) );
BOOST_STATIC_CONSTANT( std::size_t, bit_count = Bits ); BOOST_STATIC_CONSTANT( std::size_t, bit_count = Bits );

View File

@ -159,6 +159,8 @@ template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Valu
struct static_unsigned_max; struct static_unsigned_max;
namespace integer
{
// From <boost/integer/common_factor_ct.hpp> // From <boost/integer/common_factor_ct.hpp>
#ifdef BOOST_NO_INTEGRAL_INT64_T #ifdef BOOST_NO_INTEGRAL_INT64_T
@ -180,6 +182,7 @@ template < typename IntegerType >
template < typename IntegerType > template < typename IntegerType >
class lcm_evaluator; class lcm_evaluator;
} // namespace integer
} // namespace boost } // namespace boost

View File

@ -19,11 +19,13 @@ test-suite integer
[ compile static_log2_include_test.cpp ] [ compile static_log2_include_test.cpp ]
[ compile static_min_max_include_test.cpp ] [ compile static_min_max_include_test.cpp ]
[ compile integer_fwd_include_test.cpp ] [ compile integer_fwd_include_test.cpp ]
[ compile gcd_constexpr14_test.cpp ]
[ compile-fail fail_int_exact.cpp ] [ compile-fail fail_int_exact.cpp ]
[ compile-fail fail_int_fast.cpp ] [ compile-fail fail_int_fast.cpp ]
[ compile-fail fail_int_least.cpp ] [ compile-fail fail_int_least.cpp ]
[ compile-fail fail_uint_exact.cpp ] [ compile-fail fail_uint_exact.cpp ]
[ compile-fail fail_uint_fast.cpp ] [ compile-fail fail_uint_fast.cpp ]
[ compile-fail fail_uint_least.cpp ] [ compile-fail fail_uint_least.cpp ]
[ compile-fail fail_uint_65.cpp ]
[ run common_factor_test.cpp ] [ run common_factor_test.cpp ]
; ;

13
test/fail_uint_65.cpp Normal file
View File

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

View File

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

View File

@ -18,6 +18,7 @@
#include <boost/detail/lightweight_test.hpp> // for main, BOOST_TEST #include <boost/detail/lightweight_test.hpp> // for main, BOOST_TEST
#include <boost/integer.hpp> // for boost::int_t, boost::uint_t #include <boost/integer.hpp> // for boost::int_t, boost::uint_t
#include <boost/type_traits/is_same.hpp> #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 <climits> // for ULONG_MAX, LONG_MAX, LONG_MIN
#include <iostream> // for std::cout (std::endl indirectly) #include <iostream> // for std::cout (std::endl indirectly)