-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[fmtlib trunk] Including both "fmt/std.h" and "fmt.ranges.h" causes Visual Studio compiler error #2954
Comments
Thanks for reporting. Could you check if this workaround Lines 400 to 401 in e29c2bc
|
Sure. I assume you mean I should try to build the project via cmake without this conditional or do you have a special test case in mind that was the reason to introduce it? |
Short feedback: Just eliminating the conditional makes the Visual Studio builds fail for 2019 and 2022, so the existing comment should be extended to mention 2022 as well. I have not attempted to fully understand the source of the problem right now, this would need more time. |
I made progress on this issue. I found the following to be an effective approach: I'm planning to make a pull-request following this suggestion, OK? |
Sounds good. Thanks for investigating the issue! |
…tter specializations for ranges and maps more robust (especially for Visual Studio compiler family)
…td::filesystem::path> partial template specialization into two explicit specialization.
…tter specializations for ranges and maps more robust (especially for Visual Studio compiler family)
…td::filesystem::path> partial template specialization into two explicit specialization.
…2957) * #2954: Provide std::conjunction and std::disjunction substitutes * #2954: Use conjunction and disjunction substitute to make formatter specializations for ranges and maps more robust (especially for Visual Studio compiler family) * #2954: As workaround for older MSVC compilers split formatter<std::filesystem::path> partial template specialization into two explicit specialization. * 2954: Add test case * Provide simplified implementations of conjunction and disjunction * Remove workaround explicit specializations if the partial specialization would cause an ambiguity error * Eliminate extra-test and merge it into existing std-test instead. Add conditionals for filesystem::path testing that does not run into the ambiguity problem.
Tested on fmtlib trunk downloaded at 2022-06-29. The following complete code leads to a compiler error for Visual Studio compilers (Tested for VS 2019 and VS 2022 targeting C++17):
The produced error is:
I'm aware that the problem does not occur for gcc or clang, the most likely reason is the special exclusion code involving
in ranges.h#L401, but we really need to support VS 2019 for quite a while. The reason for that workaround code is not quite clear to me, but it is possible as a workaround even in the presence of this workaround to replace the partial specialization in std.h#L54 by two specializations
to solve the issue.
The issue is rather severe, because it happens quite often that you need both
ranges.h
andstd.h
in the same translation unit.I recommend to add at least the here described code as test case regardless of the actual solution.
I'd like to point out that we stumbled across this problem when we borrowed the technique described in issue 2778 but using the same partial template specialization technique that is used in
std.h
, so this also likely happens if user-code attempts to adopt the technique described in that issue.I'm open to make a corresponding pull request, but would like to get feedback on the preferred resolution.
The text was updated successfully, but these errors were encountered: