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
C++20 requires expressions not supported #7296
Comments
Similarly to #7295: I'm not sure if a mangling scheme has been decided yet in the Itanium ABI. Though, as long as the expression is not used in a context where an ID is required, this shouldn't block the feature completely. |
I am not sure what parsing of the source code has to do with name mangling for linker use? |
Consider two constrained functions template<typename T>
requires requires(T a) { something }
int f(T t);
template<typename T>
requires requires(T b) { somethingElse }
int f(T t); To get a unique ID (which is stable under permutation of your documentation) the two declarations must be mangled somehow. In Sphinx I opted for sort-of-following an existing mangling schemes. Another issue is the question of how to render these expressions. When writing them in inline text (e.g., |
Yeah, I agree that you need to internally mangle the name. I just did know that you try to follow compiler's mangling scheme which should not be a strong requirement here as the tool does not process produced binaries. Regarding the ideas, you can refer to C++20 |
It is indeed not a strong requirement, and there are definitely deviations, but making up IDs for arbitrary C++ code is no easy task :-). |
Implements the simplest case of sphinx-doc#7296, but without proper ID generation.
I would also like to see this. One use case even for pre-C++-20 use is to post-process e.g. doxygen XML output in order to convert std::enable_if to requires expressions for the purpose of clearer documentation. It seems to me that in lieu of mangling you could accomplish something similar to the existing mangling by just normalizing whitespace and hashing the text of the declaration (e.g. with sha2-256). However, I don't think mangling (whether the current scheme inspired by itanium ABI, or the simpler hashing scheme) is necessarily the right approach for producing documentation identifiers, because we may want the documentation identifiers to be more stable than the ABI, since C++ libraries often maintain only source compatibility at best, and don't maintain ABI compatibility. For example you might add an additional parameter with a default value. That breaks ABI but you don't necessarily want to break documentation links. Instead, I would propose that the user be able to specify an explicit "overload id" that is combined with the full name to produce the full name, rather than using a mangling scheme, e.g. an /// Does something or other with Foo.
///
/// Overload:
/// foo
void func(Foo foo);
/// Does something or other with Bar
///
/// Overload:
/// bar
void func(Bar bar); And the documentation generation pipeline would somehow extract those and make sure the overload-id is passed to Then these functions could be identified by I have implemented a scheme very much like this to deal with overloaded Python functions produced by pybind11, and have found it to work well, though I have only implemented it a week or so ago so I don't have a ton of experience using it. |
I prefer to have the IDs somewhat readable, it has helped with debugging earlier, but hashing may indeed be a good stop-gap until a better solution can be found. Non-parameterised requires expressions are likely to be merged soon (https://github.com/jakobandersen/sphinx/tree/cpp_requires_expr). Regarding the IDs and overloading. Generally the IDs are for internal use, but are of course exposed in formats like HTML. Though, they are not intended to be handled other than for copy-paste. |
Implements the simplest case of sphinx-doc#7296, but without proper ID generation.
See sphinx-doc#7296. Still without proper ID generation, and without sub-scopes.
See sphinx-doc#7296. Still without proper ID generation, and without sub-scopes.
I think as much of this feature that can be implemented is now in PR #9377. It would be great if people you test it. |
Implements the simplest case of sphinx-doc#7296, but without proper ID generation.
See sphinx-doc#7296. Still without proper ID generation, and without sub-scopes.
@jakobandersen, thanks for your efforts! I do not know if that helps but I've just updated Doxygen dependency in my library to 1.9.1 (it was added to Conan recently). |
Hi! What’s the status of the |
They are supported with some limitations. Many limitations are fixed in #10286 which still needs to be reviewed/merged. |
Great! Should the documentation be updated? It currently says |
Indeed, the docs are outdated. |
Oh, I see, thanks for the clarification! |
Could you please add the support for C++ requires expressions?
I am the author of mp-units which is a Physical Units Library targeting C++23 and implemented in C++20. You can find the initial version of docs here: https://mpusz.github.io/units/index.html. That documentation is meant to help with getting user's feedback before C++ standardization so it would be great if you could help here.
The text was updated successfully, but these errors were encountered: