2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Minor update for pow<N>():

Add a few more constexpr tests for the corner cases.
Document the constexpr-ness.
See https://github.com/boostorg/math/issues/354.
This commit is contained in:
jzmaddock
2020-07-06 19:29:28 +01:00
parent ceea26d144
commit b5d925de98
2 changed files with 10 additions and 2 deletions

View File

@@ -10,10 +10,10 @@ power of a run-time base.
namespace boost { namespace math {
template <int N, typename T>
``__sf_result`` pow(T base);
constexpr ``__sf_result`` pow(T base);
template <int N, typename T, class Policy>
``__sf_result`` pow(T base, const Policy& policy);
constexpr ``__sf_result`` pow(T base, const Policy& policy);
}}
@@ -60,6 +60,10 @@ For example:
* If T is a `long double`, the return type is a `long double`.
* Otherwise, the return type is a `double`.
[h4 constexpr]
This function is usable in `constexpr` contexts from C++14 onwards.
[h4 Policies]
[optional_policy]

View File

@@ -196,6 +196,10 @@ BOOST_AUTO_TEST_CASE( test_main )
#ifndef BOOST_NO_CXX14_CONSTEXPR
static_assert(boost::math::pow<8>(2)==256, "Pow is not constexpr");
static_assert(boost::math::pow<9>(2)==512, "Pow is not constexpr");
static_assert(boost::math::pow<2>(2)==4, "Pow is not constexpr");
static_assert(boost::math::pow<1>(2)==2, "Pow is not constexpr");
static_assert(boost::math::pow<0>(2)==1, "Pow is not constexpr");
#endif
test_return_types();