Skip to content
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

Constexpr cleanup #403

Merged
merged 7 commits into from
Jan 23, 2024
Merged
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
23 changes: 15 additions & 8 deletions .github/workflows/wide_integer.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ------------------------------------------------------------------------------
# Copyright Christopher Kormanyos 2020 - 2023.
# Copyright Christopher Kormanyos 2020 - 2024.
# 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)
Expand Down Expand Up @@ -525,17 +525,25 @@ jobs:
MSBuild -m wide_integer_vs2022.sln -p:useenv=true -p:Configuration=Release -p:Platform=x64 /t:Rebuild
dir %cd%\x64\Release\wide_integer_vs2022.exe
%cd%\x64\Release\wide_integer_vs2022.exe
mingw-winhost-x64:
runs-on: windows-2019
msys2-winhost-x64:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
strategy:
fail-fast: false
matrix:
compiler: [ g++ ]
standard: [ c++14, c++2a ]
standard: [ c++14, c++20 ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
install: git mingw-w64-ucrt-x86_64-gcc
- name: clone-submods-bootstrap-headers-boost-develop
run: |
git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
Expand All @@ -545,15 +553,14 @@ jobs:
git submodule update --init libs/multiprecision
./bootstrap.bat
./b2 headers
- name: mingw-winhost-x64
shell: cmd
- name: msys2-winhost-x64
working-directory: ./
run: |
echo compile ./wide_integer.exe
${{ matrix.compiler }} -v
${{ matrix.compiler }} -finline-functions -m64 -O3 -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -std=${{ matrix.standard }} -DWIDE_INTEGER_HAS_LIMB_TYPE_UINT64 -I. -I../boost-root -pthread -lpthread test/test.cpp test/test_uintwide_t_boost_backend.cpp test/test_uintwide_t_edge_cases.cpp test/test_uintwide_t_examples.cpp test/test_uintwide_t_float_convert.cpp test/test_uintwide_t_int_convert.cpp test/test_uintwide_t_n_base.cpp test/test_uintwide_t_n_binary_ops_base.cpp test/test_uintwide_t_spot_values.cpp examples/example000_numeric_limits.cpp examples/example000a_builtin_convert.cpp examples/example001_mul_div.cpp examples/example001a_div_mod.cpp examples/example002_shl_shr.cpp examples/example003_sqrt.cpp examples/example003a_cbrt.cpp examples/example004_rootk_pow.cpp examples/example005_powm.cpp examples/example005a_pow_factors_of_p99.cpp examples/example006_gcd.cpp examples/example007_random_generator.cpp examples/example008_miller_rabin_prime.cpp examples/example008a_miller_rabin_prime.cpp examples/example009_timed_mul.cpp examples/example009a_timed_mul_4_by_4.cpp examples/example009b_timed_mul_8_by_8.cpp examples/example010_uint48_t.cpp examples/example011_uint24_t.cpp examples/example012_rsa_crypto.cpp examples/example013_ecdsa_sign_verify.cpp examples/example014_pi_spigot_wide.cpp -o wide_integer.exe
dir %cd%\wide_integer.exe
%cd%\wide_integer.exe
ls -la ./wide_integer.exe
./wide_integer.exe
cygwin-winhost-x64:
runs-on: windows-latest
strategy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wide_integer_codecov.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ------------------------------------------------------------------------------
# Copyright Christopher Kormanyos 2022 - 2023.
# Copyright Christopher Kormanyos 2022 - 2024.
# 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)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wide_integer_sonar.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ------------------------------------------------------------------------------
# Copyright Christopher Kormanyos 2022 - 2023.
# Copyright Christopher Kormanyos 2022 - 2024.
# 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)
Expand Down
41 changes: 8 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ as shown in the [examples](./examples).
- Clean header-only C++14 design.
- Seamless portability to any modern C++14, 17, 20, 23 compiler and beyond.
- Scalability with small memory footprint and efficiency suitable for both PC/workstation systems as well as _bare-metal_ embedded systems.
- C++14 `constexpr`-_ness_ for construction, cast to built-in types, binary arithmetic, comparison operations, some elementary functions and more.
- C++14 `constexpr`-_ness_.

## Quick start

Expand Down Expand Up @@ -568,7 +568,6 @@ enabled or disabled at compile time with the compiler switches:
#define WIDE_INTEGER_HAS_MUL_8_BY_8_UNROLL
#define WIDE_INTEGER_DISABLE_TRIVIAL_COPY_AND_STD_LAYOUT_CHECKS
#define WIDE_INTEGER_NAMESPACE
#define WIDE_INTEGER_DISABLE_WIDE_INTEGER_CONSTEXPR
#define WIDE_INTEGER_DISABLE_PRIVATE_CLASS_DATA_MEMBERS
#define WIDE_INTEGER_HAS_CLZ_LIMB_OPTIMIZATIONS
```
Expand Down Expand Up @@ -722,29 +721,6 @@ In this default state, `namespace` `::math::wide_integer` is used
and the `uintwide_t` class and its associated implementation
details reside therein.

Domain-specific, non-supported prototyping can be (partially)
enabled by defining the macro

```cpp
#define WIDE_INTEGER_DISABLE_WIDE_INTEGER_CONSTEXPR
```

This advanced macro disables most C++14 (and beyond) `constexpr` features.
It also disables standard layout and trivially constructable
attributes.This macro can be used (if needed)
when progressive prototyping or other non-standard investigations
require disabling most of wide-integer's default-supplied
C++14 `constexpr`-handling.

This might be useful when _manually_ substituting
non-standard, alternate containers instead of using
wide-integer's default-supplied containers.
Note: During verification steps of wide-integer,
for instance, this macro has been used when performing
algorithmic proof-of-concept via use of `std::list`
for storage containters (instead of the default-supplied
dynamic/static array-like containers).

```cpp
#define WIDE_INTEGER_DISABLE_PRIVATE_CLASS_DATA_MEMBERS
```
Expand Down Expand Up @@ -779,11 +755,11 @@ is not defined and CLZ-limb optimizations are default-_disabled_.

### C++14, 17, 20, 23 and beyond `constexpr` support

When using C++14 and beyond, `uintwide_t` supports compile-time
`constexpr` construction and evaluation of results
of binary arithmetic, comparison operators
and various elementary functions.
The following code, for instance, shows compile-time instantiations
`uintwide_t` supports C++14 (and beyond) compile-time
`constexpr`-ness for all constructions, casts, operations,
evaluation of function results, etc.

The code below, for instance, shows compile-time instantiations
of `uintwide_t` from character strings with subsequent `constexpr` evaluations
of binary operations multiply, divide, intergal cast and comparison.

Expand Down Expand Up @@ -873,9 +849,8 @@ in the wide-integer project.
For sufficiently modern standards-conforming compilers,
namespace-specific functions `to_chars()` and `from_chars()`
are available. These each have the _usual_ `<charconv>`-like
behavior and can also be used in `constexpr`-context.
For motivational words on these, see also
[issue 398](https://github.com/ckormanyos/wide-integer/issues/398).
behavior, known from C++17. For motivational words to/from-chars,
see also [issue 398](https://github.com/ckormanyos/wide-integer/issues/398).

Support for importing and exporting bits is granted by the subroutines
`import_bits()` and `export_bits()`. Their interfaces, input/output forms
Expand Down
Loading