-
Notifications
You must be signed in to change notification settings - Fork 11
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
Enforce user literals parsing #50
Conversation
UDLs will never receive the negative sign? Unary minus is an operator, not part of a literal. https://godbolt.org/z/M1hneGfj7 |
See the point. My understanding wasn't correct. Hence, think it can be split in following steps:
Am I missing something? |
I think you can just remove the negative decimal integer concept and it's fine. The library should already handle unary minus. |
Gotcha. Haven't seen anything in dsl/minus.hpp, but found later in var. |
Restructuring the PR. |
50e8eab
to
684a8ac
Compare
ab702fe
to
2b01d0d
Compare
@elbeno are there any specific requirements for clang-format? Is the style based on LLVM or Google? |
0cfb20f
to
3ee899f
Compare
6620c04
to
6def723
Compare
@elbeno which parameters should I use to properly apply |
Build the target(s) |
@elbeno I'm getting the code formatted with |
6def723
to
3ad29a9
Compare
I've noticed unary negation is not supported by unsigned types. Would be a topic for another PR. |
This repo pulls in various CI stuff -- including |
With a clean repo, what I normally do is: $ cmake -Bbuild
$ TOOLCHAIN_ROOT=/usr/lib/llvm-17 cmake --preset clang --fresh
$ ninja -C build <target> The first cmake run sets up the symlinks from the CICD repo, including the presets file. This is only necessary once. The second cmake run is the "real" one that uses llvm-17 (installed from the script at apt.llvm.org) and the symlnked presets file. After that, you can build any target you like. |
This method doesn't work in Windows. Looks like presets expect clang++ binaries to be in Linux-based directories ( |
WSL will work. |
Will try to get it working with WSL |
So, still struggling to get it working: Ran $ sudo apt install libc-bin
$ sudo apt install build-essential
$ llvm.sh 17 # script from apt.llvm.org
$ sudo apt install clang-tools-17 clang-format-17 clang-tidy-17
$ cd safe-arithmetic
$ cmake -Bbuild -GNinja
$ TOOLCHAIN_ROOT=/usr/lib/llvm-17 cmake --preset clang --fresh
$ ninja -C build check-clang-format # failed The last command faild with error: Format.cmake: cannot run because clang-format and/or python not found $ ln -s /usr/bin/clang-format-17 /usr/bin/clang-format
$ ln -s /usr/bin/clang-tidy-17 /usr/bin/clang-tidy
$ ln -s /usr/bin/python3 /usr/bin/python That didn't help. So, On the other hand, I've tried
|
Closes #11
Current implementation contains a 🐛 bug. Compilation will fail for invalid values captured by user literals. Such weakness puts in danger the whole purpose of the safety library. Stronger user literals parsing is needed.
This PR adds strong support for positive decimal and hexadecimal numbers. The support is provided through creation of three concepts:
hex_integer
anddecimal_integer
. These concepts match provided values with intended types and dispatch appropriate parsing function. So, additional safety is provided.