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

Add support for C++20 concepts #166

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add support for C++20 concepts #166

wants to merge 2 commits into from

Conversation

svenevs
Copy link
Owner

@svenevs svenevs commented Jun 17, 2022

CC @lums658 refs #160 I couldn't push to that branch (I think because it's the main branch of your repo), I'm sorry for the very long delay. In order to support C++ concepts I needed to fix the testing framework for doxygen 1.9.x in order to actually test for this. This one will take me some time to flesh out entirely (there's a handful of test framework changes which would be a nightmare for not me (well for me too, but way worse for anyone else)).

However, would you be willing to add some code to the newly created testing/projects/cpp_concepts/include/concepts/concepts.hpp and associated usages (where applicable) in src/tests.cpp? The tests.cpp exists mostly to guarantee that anything added in concepts.hpp actually compiles. The infrastructure is up, but it would be really helpful to have a more exhaustive list of concepts code -- I'm not up to speed, just anything that would stress test doxygen / breathe from a documentation perspective. Note the testing code license is CC0 (please add yourself to the license at the top though!). Only other rule for code there is keep it PG-13, but otherwise the content (or docs) are less than meaningful anywhere else 😉

I get the impression it would be fairly easy for you to PR to this branch with some nice modern concepts code there 🙏

There's definitely no rush ... it'll take me some time to finalize things (I anticipate CI being troublesome here), but after the code is in place I will be able to inspect the implementation / create unit tests for the project. Having the test project in place helps me look at the output of exhale and confirm it's working as desired.

@hobbeshunter
Copy link

Just want to say that I'm quite interested in concepts support as well.

@svenevs
Copy link
Owner Author

svenevs commented Nov 20, 2022

The doxygen compatibility problems have been resolved, but I still need test code that exhausts concepts options. Been perusing cppreference but still trying to work it out (haven't had the luxury of using c++20 in production and not enough time to catch up on my own).

Questions that come up:

  • Is there any concept inheritance?
  • Can there be nested concepts (like nested classes / structs, or can a concept be declared in a nested scope like in a class definition)?
  • Any other known "fancy edge cases"?

I'm definitely down to merge something we think covers the bases and fix it later if needed. But having code on the tests is required, it's the only reason this project still limps along. The absurd implementation is brittle and small changes elsewhere can and do break other things. Sample code would be most welcome (header file and usage examples). From there I can integrate that code into the rest of the (very complicated) testing framework. I've got some flights coming up, the last one I was able to make some good progress on updating tree view html / css. This one is also high priority for me, lack of concepts is an eyesore (it's almost 2023!)

@lums658
Copy link

lums658 commented Nov 20, 2022 via email

@svenevs
Copy link
Owner Author

svenevs commented Nov 20, 2022

No apology necessary, I responded very late... Ok, great, thank you so much!!! To be clear I only need help with the C++ source code, the python side / exhale test case side I will take care of 🙂

@hobbeshunter
Copy link

Thanks for the fast response. Maybe I can help a bit.

Can there be nested concepts (like nested classes / structs, or can a concept be declared in a nested scope like in a class definition)?

Not to my knowledge.

Is there any concept inheritance?

I don't think so. But you can combine concepts easily, like

template <typename T>
concept Number = std::integral<T> || std::floating_point<T>;

(Taken from https://www.sandordargo.com/blog/2021/02/24/cpp-concepts-with-classes)

Any other known "fancy edge cases"?

According to cppreference there are three types of constraints:

  1. conjunctions
  2. disjunctions
  3. atomic constraints

So having an example per type seems to be a good start.

One edge case might be the inline declaration of a concept. Although bad style it's valid:

template <typename T> requires requires (T x) { x + x; }
T add(T a, T b) { return a + b; }

See it on compiler explorer.. But I'm not sure how this should be documented.

@renefritze
Copy link

What can I do to help get this PR into a state that you'd be happy to merge @svenevs ?

@renefritze renefritze mentioned this pull request Aug 7, 2024
@svenevs
Copy link
Owner Author

svenevs commented Aug 7, 2024

Thank you so much, I've cleared Saturday, let's keep working with #218 and #219.

I will do final passes but ultimately rely on user testing. If it's working on your codebase then we merge. Fix problems if people report them.

Main expected snag is getting breathe_identifier implemented correctly. Historically breathe is very sensitive to whitespace issues. thing< specialized > with spaces, not thing<specialized> for example. Refer to the generated doxygen xml for the answer, that's what breathe uses (or at least used to). The defname and declname I think?

Thank you again for putting time into this, I will get back to you as soon as I can!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants