Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ exe has_eigen : has_eigen.cpp ;
exe has_f2c : has_f2c.cpp f2c ;
obj has_is_constant_evaluated : has_is_constant_evaluated.cpp ;
obj has_constexpr_limits : has_constexpr_limits_cmd.cpp : <cxxflags>-fconstexpr-ops-limit=268435456 ;
obj has_constexpr_dynamic_memory : has_constexpr_dynamic_memory.cpp : <cxxflags>-std=c++2a ;
obj has_big_obj : has_big_obj.cpp : <cxxflags>-Wa,-mbig-obj ;
obj is_ci_sanitizer_run : is_ci_sanitizer_run.cpp ;

Expand All @@ -90,6 +91,7 @@ explicit has_mpc ;
explicit has_eigen ;
explicit has_is_constant_evaluated ;
explicit has_constexpr_limits ;
explicit has_constexpr_dynamic_memory ;
explicit has_big_obj ;
explicit has_f2c ;
explicit is_ci_sanitizer_run ;
25 changes: 25 additions & 0 deletions config/has_constexpr_dynamic_memory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright John Maddock 2025.
// 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)

#include <memory>


#if !defined(__cpp_constexpr_dynamic_alloc)
# error "__cpp_constexpr_dynamic_alloc is not defined"

#elif __cpp_constexpr_dynamic_alloc < 201907
# error "__cpp_constexpr_dynamic_alloc is defined with value < 201907"

#elif !defined(__cpp_lib_constexpr_dynamic_alloc)
# error "__cpp_lib_constexpr_dynamic_alloc is not defined"

#elif __cpp_lib_constexpr_dynamic_alloc < 201907
# error "__cpp_lib_constexpr_dynamic_alloc is defined with value < 201907"
#endif

int main()
{
return 0;
}
357 changes: 216 additions & 141 deletions include/boost/multiprecision/cpp_int.hpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion include/boost/multiprecision/cpp_int/cpp_int_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ using signed_double_limb_type = detail::largest_signed_type<64>::type ;
constexpr limb_type max_block_10 = 1000000000;
constexpr limb_type digits_per_block_10 = 9;

inline limb_type block_multiplier(std::size_t count)
inline BOOST_MP_CXX14_CONSTEXPR limb_type block_multiplier(std::size_t count)
{
constexpr limb_type values[digits_per_block_10] = {10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};
BOOST_MP_ASSERT(count < digits_per_block_10);
Expand Down
98 changes: 61 additions & 37 deletions include/boost/multiprecision/cpp_int/limits.hpp

Large diffs are not rendered by default.

30 changes: 16 additions & 14 deletions include/boost/multiprecision/detail/empty_value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace boost { namespace multiprecision { namespace detail {

template <typename T>
struct use_empty_value_base
struct use_empty_value_base
{
#if defined(BOOST_DETAIL_EMPTY_VALUE_BASE)
static constexpr bool value = __is_empty(T) && !__is_final(T);
Expand All @@ -38,7 +38,7 @@ struct empty_init_t {};

namespace empty_impl {

template <typename T, unsigned N = 0,
template <typename T, unsigned N = 0,
bool E = boost::multiprecision::detail::use_empty_value_base<T>::value>
class empty_value
{
Expand All @@ -48,15 +48,16 @@ class empty_value
public:
using type = T;

empty_value() = default;
explicit empty_value(boost::multiprecision::detail::empty_init_t) : value_ {} {}
BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR empty_value() = default;
explicit BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR empty_value(boost::multiprecision::detail::empty_init_t)
: value_ {} {}

template <typename U, typename... Args>
empty_value(boost::multiprecision::detail::empty_init_t, U&& value, Args&&... args) :
value_ {std::forward<U>(value), std::forward<Args>(args)...} {}
BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR empty_value(boost::multiprecision::detail::empty_init_t, U&& value, Args&&... args)
: value_ {std::forward<U>(value), std::forward<Args>(args)...} {}

const T& get() const noexcept { return value_; }
T& get() noexcept { return value_; }
BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR const T& get() const noexcept { return value_; }
BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR T& get() noexcept { return value_; }
};

template <typename T, unsigned N>
Expand All @@ -65,15 +66,16 @@ class empty_value<T, N, true> : T
public:
using type = T;

empty_value() = default;
explicit empty_value(boost::multiprecision::detail::empty_init_t) : T{} {}
BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR empty_value() = default;
explicit BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR empty_value(boost::multiprecision::detail::empty_init_t)
: T{} {}

template <typename U, typename... Args>
empty_value(boost::multiprecision::detail::empty_init_t, U&& value, Args&&... args) :
T{std::forward<U>(value), std::forward<Args>(args)...} {}
BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR empty_value(boost::multiprecision::detail::empty_init_t, U&& value, Args&&... args)
: T{std::forward<U>(value), std::forward<Args>(args)...} {}

const T& get() const noexcept { return *this; }
T& get() noexcept { return *this; }
BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR const T& get() const noexcept { return *this; }
BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR T& get() noexcept { return *this; }
};

} // Namespace empty impl
Expand Down
27 changes: 27 additions & 0 deletions include/boost/multiprecision/detail/number_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,33 @@
# define BOOST_CXX14_CONSTEXPR_IF_DETECTION constexpr
#endif

#if defined(__cpp_constexpr_dynamic_alloc) && __cpp_constexpr_dynamic_alloc >= 201907L \
&& defined(__cpp_lib_constexpr_dynamic_alloc) && __cpp_lib_constexpr_dynamic_alloc >= 201907L
# undef BOOST_MP_HAS_CONSTEXPR_DYNAMIC_ALLOC
# define BOOST_MP_HAS_CONSTEXPR_DYNAMIC_ALLOC

# undef BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR
# define BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR constexpr

#else
# undef BOOST_MP_HAS_CONSTEXPR_DYNAMIC_ALLOC
# define BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR
#endif

#if !defined(BOOST_MP_NO_CONSTEXPR_DETECTION) && defined(BOOST_MP_HAS_CONSTEXPR_DYNAMIC_ALLOC)
# undef BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR_IF_DETECTION
# define BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR_IF_DETECTION constexpr

# undef BOOST_MP_NO_CXX20_DYNAMIC_ALLOC_CONSTEXPR_DETECTION

#else
# undef BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR_IF_DETECTION
# define BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR_IF_DETECTION

# undef BOOST_MP_NO_CXX20_DYNAMIC_ALLOC_CONSTEXPR_DETECTION
# define BOOST_MP_NO_CXX20_DYNAMIC_ALLOC_CONSTEXPR_DETECTION
#endif

#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable : 6326)
Expand Down
28 changes: 28 additions & 0 deletions include/boost/multiprecision/detail/standalone_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,32 @@ namespace boost { namespace multiprecision {
# endif
#endif

#if defined(__cpp_constexpr_dynamic_alloc) && __cpp_constexpr_dynamic_alloc >= 201907L \
&& defined(__cpp_lib_constexpr_dynamic_alloc) && __cpp_lib_constexpr_dynamic_alloc >= 201907L
# undef BOOST_MP_HAS_CONSTEXPR_DYNAMIC_ALLOC
# define BOOST_MP_HAS_CONSTEXPR_DYNAMIC_ALLOC

# undef BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR
# define BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR constexpr

#else
# undef BOOST_MP_HAS_CONSTEXPR_DYNAMIC_ALLOC
# define BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR
#endif

#if !defined(BOOST_MP_NO_CONSTEXPR_DETECTION) && defined(BOOST_MP_HAS_CONSTEXPR_DYNAMIC_ALLOC)
# undef BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR_IF_DETECTION
# define BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR_IF_DETECTION constexpr

# undef BOOST_MP_NO_CXX20_DYNAMIC_ALLOC_CONSTEXPR_DETECTION

#else
# undef BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR_IF_DETECTION
# define BOOST_MP_CXX20_DYNAMIC_ALLOC_CONSTEXPR_IF_DETECTION

# undef BOOST_MP_NO_CXX20_DYNAMIC_ALLOC_CONSTEXPR_DETECTION
# define BOOST_MP_NO_CXX20_DYNAMIC_ALLOC_CONSTEXPR_DETECTION
#endif


#endif // BOOST_MP_STANDALONE_CONFIG_HPP
5 changes: 4 additions & 1 deletion test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,8 @@ test-suite misc :
[ run constexpr_test_cpp_int_5.cpp : : : [ requires cxx14_constexpr cxx17_if_constexpr ] [ check-target-builds ../config//has_is_constant_evaluated : : <build>no ] ]
[ run constexpr_test_cpp_int_6.cpp : : : [ requires cxx14_constexpr cxx17_if_constexpr ] [ check-target-builds ../config//has_is_constant_evaluated : <toolset>msvc:<cxxflags>-constexpr:steps10000000 <toolset>clang:<cxxflags>-fconstexpr-steps=268435456 : <build>no ] [ check-target-builds ../config//has_constexpr_limits : <cxxflags>-fconstexpr-ops-limit=268435456 ] ]
[ run constexpr_test_cpp_int_7.cpp : : : [ requires cxx14_constexpr cxx17_if_constexpr ] [ check-target-builds ../config//has_is_constant_evaluated : <toolset>msvc:<cxxflags>-constexpr:steps10000000 <toolset>clang:<cxxflags>-fconstexpr-steps=268435456 : <build>no ] ]
[ run constexpr_test_dynamic_cpp_int_1.cpp : : : [ requires cxx14_constexpr cxx17_if_constexpr ] [ check-target-builds ../config//has_constexpr_dynamic_memory : <toolset>msvc:<cxxflags>-constexpr\:steps10000000 <toolset>clang:<cxxflags>-fconstexpr-steps=268435456 <cxxflags>-std=c++2a : <build>no ] ]
[ run constexpr_test_dynamic_cpp_int_2.cpp : : : [ requires cxx14_constexpr cxx17_if_constexpr ] [ check-target-builds ../config//has_constexpr_dynamic_memory : <toolset>msvc:<cxxflags>-constexpr\:steps10000000 <toolset>clang:<cxxflags>-fconstexpr-steps=268435456 <cxxflags>-std=c++2a : <build>no ] ]

[ compile test_nothrow_cpp_int.cpp ]
[ compile test_nothrow_cpp_rational.cpp ]
Expand Down Expand Up @@ -1297,7 +1299,8 @@ test-suite standalone :
[ run standalone_constexpr_test_cpp_int.cpp : : : [ requires cxx14_constexpr cxx17_if_constexpr ] [ check-target-builds ../config//has_is_constant_evaluated : : <build>no ] ]
[ compile standalone_constexpr_test_float128.cpp :
[ requires cxx14_constexpr cxx17_if_constexpr ] [ check-target-builds ../config//has_float128 : <source>quadmath : <build>no ] ]

[ run standalone_constexpr_test_dynamic_cpp_int.cpp : : : [ requires cxx14_constexpr cxx17_if_constexpr ] [ check-target-builds ../config//has_constexpr_dynamic_memory : <toolset>msvc:<cxxflags>-constexpr\:steps10000000 <toolset>clang:<cxxflags>-fconstexpr-steps=268435456 <cxxflags>-std=c++2a : <build>no ] ]

[ run standalone_test_arithmetic_complex128.cpp : : : [ check-target-builds ../config//has_float128 : <source>quadmath ] ]
[ run standalone_test_arithmetic_cpp_bin_float.cpp no_eh_support : : : <toolset>msvc:<cxxflags>-bigobj [ check-target-builds ../config//has_float128 : <source>quadmath ] ]
[ run standalone_test_arithmetic_cpp_dec_float.cpp no_eh_support : : : <toolset>msvc:<cxxflags>-bigobj [ check-target-builds ../config//has_float128 : <source>quadmath ] ]
Expand Down
Loading
Loading