Skip to content

Add ADL swap() function. - #128

Merged
Kim-J-Smith merged 3 commits into
version-2.2.1from
v2.2.1/swap
Aug 9, 2026
Merged

Add ADL swap() function.#128
Kim-J-Smith merged 3 commits into
version-2.2.1from
v2.2.1/swap

Conversation

@Kim-J-Smith

Copy link
Copy Markdown
Owner

feat & perf: add ADL swap() function.

ADLSwapBenchmark.fn_swap_trivial:

Name (* = baseline) Dim Total ms ns/op Baseline Ops/second
use_std_swap_trivial * 10000 0.110 11 - 90661831.4
use_adl_swap_trivial 10000 0.038 3 0.345 262467191.6
use_std_swap_trivial * 100000 1.195 11 - 83703021.7
use_adl_swap_trivial 100000 0.381 3 0.319 262605042.0
use_std_swap_trivial * 1000000 11.985 11 - 83441111.4
use_adl_swap_trivial 1000000 3.814 3 0.318 262185050.2

ADLSwapBenchmark.fn_swap_non_trivial:

Name (* = baseline) Dim Total ms ns/op Baseline Ops/second
use_std_swap_non_trivial * 10000 0.143 14 - 69686411.1
use_adl_swap_non_trivial 10000 0.096 9 0.671 103842159.9
use_std_swap_non_trivial * 100000 1.403 14 - 71265678.4
use_adl_swap_non_trivial 100000 0.965 9 0.688 103659168.7
use_std_swap_non_trivial * 1000000 14.968 14 - 66808300.3
use_adl_swap_non_trivial 1000000 9.652 9 0.645 103609764.2

@Kim-J-Smith Kim-J-Smith added enhancement New feature or request new feature This is a new feature. labels Aug 9, 2026
Comment thread include/embed/embed_function.hpp Outdated
@Kim-J-Smith
Kim-J-Smith merged commit 21efb85 into version-2.2.1 Aug 9, 2026
9 checks passed
@Kim-J-Smith
Kim-J-Smith deleted the v2.2.1/swap branch August 9, 2026 13:16
@Kim-J-Smith Kim-J-Smith mentioned this pull request Aug 13, 2026
Kim-J-Smith added a commit that referenced this pull request Aug 14, 2026
**🔧 Fixed Bugs**
- Fixed freestanding support: `throw_or_terminate()` now uses `std::terminate()` and the `std::function` overload of `not_empty()` is skipped when `__STDC_HOSTED__` is not defined. (#132)
- Fixed GCC 16 ipa-cp devirtualization failure by adding `gcc_ipa_cp_friendly_cast()` so indirect calls via `m_invoker` are tracked correctly (see issue #133). (#134)
- Fixed `-Wuninitialized` warning by explicitly initializing `Base_MemberVariable` in the default/`nullptr_t`/functor constructors. (#136)
- Fixed the benchmark bug in `MoveOnlyFunction.Params.SmallTrivial` (wrong `volatile void*` usage). (#137)

**⚠️ Breaking Changes**
- None.

**✨ New Features**
- Added [ngcpp/proxy](https://github.com/ngcpp/proxy) as a benchmark target, with `proxy` cases added to all runtime benchmark suites (headers vendored in `benchmark/runtime/proxy/`). (#137)
- Added an ADL swap() free function for exchanging two same-type wrappers. (#128)

**🛠️ Optimizations and Improvements**
- Constructed `ErasurePass` directly with const pointers, adding dedicated constructors for const/volatile-qualified erased pointers. (#134)
- Simplified `operator()` by inlining the invoker call and dropping the `invoke()` helper from the command tables and removing unnecessary `const_cast`. (#134)
- Benchmarks now build with `-O2` (was `-Os`) to avoid the strange bug in MinGW, and benchmark parameters were adjusted (`BENCHMARK_TIMES {1000, 1000000}`, `BENCHMARK_REPEAT 15`). (#137)
- Updated benchmark CI to GCC-16 on Ubuntu 26.04, and README benchmark results (GCC-16, C++23, `-O2`). (#137)
- Enabled sanitizers in the test suite (non-Windows): GCC tests build with `-fsanitize=address` and Clang tests build with `-fsanitize=address,undefined`. (#130)
- Defining `DEBUG` now forces the debug diagnostics (assertions and terminate checks) to stay active even when `NDEBUG` or `__OPTIMIZE__` is defined. (#136)
- Added `[[msvc::intrinsic]]` to `gcc_ipa_cp_friendly_cast()` to help MSVC inline. (#135)

**📌 Notes**
- Benchmark now requires C++20 because of the `proxy` dependency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request new feature This is a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant