Repository navigation
Conversation
realstealthninja
left a comment
There was a problem hiding this comment.
Thanks for taking the time to raise a pr!
| #include <cassert> | ||
| #include <cstdint> | ||
| #include <iostream> |
There was a problem hiding this comment.
Includes should be documented see other files for info
| } | ||
| } // namespace bit_manipulation | ||
|
|
||
| inline static void test() noexcept { |
There was a problem hiding this comment.
Test should not be inlined
|
i changed everything as you described |
| * example: | ||
| * a = 7 = 0b111, b = 8 = 0b1000 | ||
| * a ^= b; a == 0b1111 == 15 | ||
| * b = a ^ b; b == 0b111 == 7 | ||
| * a ^= b; a = 0b1000 == 8 |
There was a problem hiding this comment.
You could probably add this to the top level documentation and convert it into a table/graphviz diagram and it would be much more legible
|
i added 5th test to actually cover every case (it won't hurt the performance if the values are equal, xor takes 3 bytes to encode on x86-64 machines, the jump instruction, e.g. the if statement will add more junk to the final code) |
Description of Change
Checklist
Notes:
i've added bit_manipulation/swap_numbers.cpp and tested it on both Debian v.13.7 and Arch Linux release 2026.10.1
it works with both clang++ and g++ ; it works in both debug (-g) and release (-O3) modes ; it works without any -W flags, and with -Wall -Wextra -Werror enabled