Skip to content
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 clause not supported #7295

Closed
mpusz opened this issue Mar 11, 2020 · 7 comments · Fixed by #7670
Closed

C++20 requires clause not supported #7295

mpusz opened this issue Mar 11, 2020 · 7 comments · Fixed by #7670
Labels
domains:cpp type:enhancement enhance or introduce a new feature

Comments

@mpusz
Copy link

mpusz commented Mar 11, 2020

Could you please add the support for C++ requires clauses?

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.

@jakobandersen
Copy link
Contributor

Instead of reinventing the wheel regarding name mangling I try to to follow (in spirit) the Itanium ABI, but it looks like the standard is not yet clear on some details (itanium-cxx-abi/cxx-abi#24).
@mpusz, do you happen to have seen mangled names with constraints? I can't get GCC to produce any so far.

@jakobandersen
Copy link
Contributor

I believe PR #7670 implements the most of the feature, including ID generation. @mpusz, can you check with your project if it fixes the cases one might expect?

What is missing, and will be deferred to later is the indentation of the lines with requires clauses (see also for a similar issue #1514).

jakobandersen added a commit to jakobandersen/sphinx that referenced this issue May 16, 2020
@mpusz
Copy link
Author

mpusz commented May 17, 2020

I checked the latest version and it still does not work but the generated errors are different. For example for the following code: https://github.com/mpusz/units/blob/master/src/include/units/quantity_cast.h#L327-L329 Sphinx 3.0.3 generated the following error:

/home/conan/.conan/data/mp-units/0.6.0/mpusz/testing/build/84fafb7fe407ee8fe81202463e0abcc961cfd947/docs/reference/functions.rst:7: WARNING: Invalid C++ declaration: Expected end of definition. [error at 129]
  template<Quantity To, typename D, typename U, typename Rep> constexpr auto units::quantity_cast (const quantity< D, U, Rep > &q) requires QuantityOf< To
  ---------------------------------------------------------------------------------------------------------------------------------^

while the PR #7670 prints:

[build] /home/mpusz/repos/units/docs/reference/functions.rst:7: WARNING: 
[build] Main error:
[build]   Invalid C++ declaration: Expected end of definition. [error at 148]
[build]     template<Quantity To, typename D, typename U, typename Rep> constexpr auto units::quantity_cast (const quantity< D, U, Rep > &q) requires QuantityOf< To
[build]     ----------------------------------------------------------------------------------------------------------------------------------------------------^
[build] Potential other error:
[build]   Error in parsing template argument list.
[build]   If type argument:
[build]     Invalid C++ declaration: Expected "...>", ">" or "," in template argument list. [error at 152]
[build]       template<Quantity To, typename D, typename U, typename Rep> constexpr auto units::quantity_cast (const quantity< D, U, Rep > &q) requires QuantityOf< To
[build]       --------------------------------------------------------------------------------------------------------------------------------------------------------^
[build]   If non-type argument:
[build]     Invalid C++ declaration: Expected "...>", ">" or "," in template argument list. [error at 152]
[build]       template<Quantity To, typename D, typename U, typename Rep> constexpr auto units::quantity_cast (const quantity< D, U, Rep > &q) requires QuantityOf< To
[build]       --------------------------------------------------------------------------------------------------------------------------------------------------------^
[build] 

@jakobandersen
Copy link
Contributor

jakobandersen commented May 17, 2020

In the code the declaration ends with requires QuantityOf<To, D> but in the shown error output the declaration looks like requires QuantityOf< To. Is this a copy-paste error, or was the output really like this? If so, it may be that Doxygen/Breathe doesn't give the right thing to Sphinx.

@mpusz
Copy link
Author

mpusz commented May 24, 2020

I am sorry, I missed your answer :-(

I confirm it is not a copy-paste error but a full line of the trace I get.

@jakobandersen
Copy link
Contributor

In that case I guess Breathe or Doxygen may have a problem. I didn't find an easy, quick way to build your docs, so I can't check.
Let's move the discussion over to the Breathe issue. I'll close this for now, as the Sphinx part seems to work as intended.

@mpusz
Copy link
Author

mpusz commented May 26, 2020

In case you are interested, you can find info on how to build docs here: https://mpusz.github.io/units/usage.html#full-mp-units-build-unit-testing-and-documentation-generation and the following remotes have to be added to Conan:
https://mpusz.github.io/units/usage.html#non-standard-conan-remotes.

jakobandersen added a commit to jakobandersen/sphinx that referenced this issue Jun 2, 2020
jakobandersen added a commit to jakobandersen/sphinx that referenced this issue Jun 2, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
domains:cpp type:enhancement enhance or introduce a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants