Compare commits

...

7 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
15 changed files with 129 additions and 63 deletions

View File

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

View File

@ -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]

View File

@ -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">

View File

@ -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">

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Integer Type Selection</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.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>

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Compile Time log2 Calculation</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.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

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Integer Masks</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.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

View File

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Compile time min/max calculation</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.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>

View File

@ -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>

View File

@ -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>

View File

@ -22,6 +22,10 @@
#include <climits> // for CHAR_MIN
#include <boost/detail/workaround.hpp>
#ifndef BOOST_NO_CXX11_NOEXCEPT
#include <boost/type_traits/is_arithmetic.hpp>
#endif
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4127 4244) // Conditional expression is constant
@ -32,14 +36,15 @@ namespace boost
namespace integer
{
#define BOOST_INT_NOEXCEPT(T) BOOST_NOEXCEPT_IF(boost::is_arithmetic<T>::value)
// Forward declarations for function templates -----------------------------//
template < typename IntegerType >
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 ---------------------//
@ -52,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
@ -68,8 +73,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::lcm_evaluator
@ -80,12 +85,12 @@ 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__
@ -110,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 );
@ -126,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 )
{
@ -190,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 );
@ -205,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 );
@ -225,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 );
}
@ -234,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 );
}
@ -243,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;
@ -259,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 );
}
@ -269,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 );
@ -290,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) ); } }
@ -316,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 );
}
@ -325,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 );
}
@ -334,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;
@ -350,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 );
}
@ -359,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;
@ -373,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;
@ -392,13 +397,13 @@ namespace detail
// 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 );
}
@ -407,13 +412,13 @@ gcd_evaluator<IntegerType>::operator ()
// Least common multiple evaluator member function definition --------------//
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 );
}
@ -422,13 +427,13 @@ lcm_evaluator<IntegerType>::operator ()
// Greatest common divisor and least common multiple function definitions --//
template < typename IntegerType >
inline
inline BOOST_CXX14_CONSTEXPR
IntegerType
gcd
(
IntegerType const & a,
IntegerType const & b
)
) BOOST_INT_NOEXCEPT(IntegerType)
{
gcd_evaluator<IntegerType> solver;
@ -436,13 +441,13 @@ gcd
}
template < typename IntegerType >
inline
inline BOOST_CXX14_CONSTEXPR
IntegerType
lcm
(
IntegerType const & a,
IntegerType const & b
)
) BOOST_INT_NOEXCEPT(IntegerType)
{
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>::fast fast;
BOOST_STATIC_CONSTANT( least, sig_bits = (~( ~(least( 0u )) << Bits )) );
BOOST_STATIC_CONSTANT( least, sig_bits = (~(least(~(least( 0u ))) << Bits )) );
BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) );
BOOST_STATIC_CONSTANT( std::size_t, bit_count = Bits );

View File

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

View File

@ -19,6 +19,7 @@ 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 ]

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