mp-units
mp-units copied to clipboard
refactor: apply TODOs about MSVC and lambdas in unevaluated contexts
According to https://en.cppreference.com/w/cpp/compiler_support, MSVC now supports them. https://godbolt.org/z/dfc3ro. bits/basic_concepts.h
has one such TODO.
I should note that Clang 12 did not implement this. If this were to be applied, we won't be able to support Clang 12. Otherwise, it seems all we'd have to do is make TYPENAME
expand to typename
, as done for MSVC. And then work out any bugs that pop up.
According to https://en.cppreference.com/w/cpp/compiler_support, MSVC now supports them. https://godbolt.org/z/dfc3ro. bits/basic_concepts.h has one such TODO.
As I am aware of for MSVC it is only supported in some Preview version and not in an officially released version? At least it does not work for me on an updated VS2019.
I have all of the changes ready for CLang support for a long time now. However, clang has some major issues with concepts and ends up in some recursive loop on both the gcc concepts library and on range-v3. So for now I am unable to make it work :-(
Push a branch. I'll check it out.
OK, see the https://github.com/mpusz/units/tree/clang_support branch.
It's currently even with master.
Sorry, try now.
I'll need to compile Clang 13 first.
I was able to compile quantity_test.cpp
with https://github.com/johelegp/units-1/commit/0dcd2940b77fcfcf67e2783b395b34fb5c6a14f6 (-DUNITS_DOWNCAST_MODE=0, libstdc++10). Otherwise, I get error: redefinition of 'downcast_guide'
. Everything's too buggy.
So do we target clang 12 or 13?
Little time has passed since Clang 12 froze and development Clang 13 started, so there should be little to no difference right now. I'd say the major blockers to adoption are #211 or -DUNITS_DOWNCAST_MODE=1
(due to the error: redefinition of 'downcast_guide'
mentioned above).
I was able to get past error: redefinition of 'downcast_guide'
by doing this change in downcasting.h
:
- if constexpr(has_downcast_guide<T> && !has_downcast_poison_pill<T>)
+ if constexpr(has_downcast_guide<downcast_base<T>> && !has_downcast_poison_pill<T>)
which is what's actually used in the return statement. Presumably, has_downcast_poison_pill
should change accordingly.
there should be little to no difference right now.
Not really. Compare this:
- main: https://github.com/llvm/llvm-project/blob/main/libcxx/include/concepts
- 12: https://github.com/llvm/llvm-project/blob/release/12.x/libcxx/include/concepts
That's the library side, though. I'll work it out on Clang trunk, and then you and maybe I could check how Clang 12 fares.
OK, I use https://apt.llvm.org/ so it is easy to have both clang-12 and clang-13-dev (both with their libc++ versions) at the same time being up-to-date all the time.
I think Clang 13 is ready. All tests compile and pass, as do the examples. glide_computer.cpp
has some warnings and I have yet to test linear_algebra.cpp
, though.
https://en.cppreference.com/w/cpp/compiler_support lists Clang 13 and 14 as partially supporting lambdas in unevaluated contexts. I personally haven't had issues using them since Clang 14.