Skip to content

Add constexpr support for dynamic allocated cpp_int #654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

marcoffee
Copy link

@marcoffee marcoffee commented Feb 13, 2025

Added constexpr support for dynamic allocated cpp_ints as long as compiler implements features __cpp_constexpr_dynamic_alloc and __cpp_lib_constexpr_dynamic_alloc from P0784R7.

If those features are disabled, it behaves as the current implementation. Note that those features require C++20, so they will only work when passing -std=c++2a (or beyond) flag during compilation through a supported compiler (tested here on g++-11+ and clang++-16+ using libstdc++ with g++-10+ toolset on ubuntu noble).

It might work on g++-10, but for some reason the b2 check for if constexpr keep returning "no" for it.

Also fixed constexpr construction from strings and added some tests for construction/operations on dynamic allocated cpp_ints.

Had to make small changes to existing code to tackle some warnings given when compiled without the feature's support (such as uninitialized variables not being supported in constexpr methods before C++20).

@marcoffee marcoffee force-pushed the feature/more-constexpr branch 4 times, most recently from 66564be to e6cb783 Compare February 14, 2025 03:11
@marcoffee marcoffee force-pushed the feature/more-constexpr branch from e6cb783 to 2c0d0cd Compare March 24, 2025 16:02
Copy link

codecov bot commented Mar 24, 2025

Codecov Report

Attention: Patch coverage is 89.72603% with 15 lines in your changes missing coverage. Please review.

Project coverage is 94.1%. Comparing base (7fac807) to head (2c0d0cd).
Report is 847 commits behind head on develop.

Files with missing lines Patch % Lines
include/boost/multiprecision/cpp_int.hpp 88.2% 15 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop    #654     +/-   ##
=========================================
- Coverage     94.1%   94.1%   -0.0%     
=========================================
  Files          279     282      +3     
  Lines        28979   29022     +43     
=========================================
+ Hits         27253   27288     +35     
- Misses        1726    1734      +8     
Files with missing lines Coverage Δ
...de/boost/multiprecision/cpp_int/cpp_int_config.hpp 100.0% <ø> (ø)
include/boost/multiprecision/cpp_int/limits.hpp 100.0% <100.0%> (ø)
...nclude/boost/multiprecision/detail/empty_value.hpp 100.0% <100.0%> (ø)
...nclude/boost/multiprecision/detail/number_base.hpp 98.0% <ø> (ø)
test/constexpr_test_dynamic_cpp_int.hpp 100.0% <100.0%> (ø)
test/constexpr_test_dynamic_cpp_int_1.cpp 100.0% <100.0%> (ø)
test/constexpr_test_dynamic_cpp_int_2.cpp 100.0% <100.0%> (ø)
include/boost/multiprecision/cpp_int.hpp 95.1% <88.2%> (-0.6%) ⬇️

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7fac807...2c0d0cd. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant