Skip to content

[SUGGESTION] C++0x concepts for cpp2 #538

Description

@AbhinavK00

Concepts in cpp20 have made generic programming easier but they still leave a lot to be desired, after all they are called concepts "lite" for a reason. P1900 describes some desired features from concepts. Along with those features, concepts are only that much useful as much as they used. Currently there is no mechanism to force the use of concepts too (which P1900 does not mention).
While this is not a full suggestion, it is more of a question if Herb would like a mechanism similar to C++0x concepts to be present in cpp2?
A lot of work was done on that feature, and it almost made it into the language except that it didn't (I don't know the reasons but Herb, as being someone from the commitee would probably know).

Alternatives considered : Interfaces in cpp2 could somehow emulate both nominal concepts and customisation points but features like associated types, type erasure are still left desired.

Activity

  1. AbhinavK00 commented on Aug 13, 2023

    @AbhinavK00
    Author

    I was hoping to get some feedback to this issue. If Herb doesn't want that in cpp2, he can close but I'd like to see what his views are.

  2. JohelEGP commented on Aug 13, 2023

    @JohelEGP
    Contributor

    See https://youtu.be/CXn02MPkn8Y?t=176.
    Apparently, C++0x concepts

    were kind of complicated and no one understood them.

  3. AbhinavK00 commented on Aug 13, 2023

    @AbhinavK00
    Author

    First of all, THANKS for a reply.
    Second of all, they were not complicated but hard to use in the final form that was agreed upon (which Bjarne didn't like and it ultimately led to their cancellation). While most of those features would probably require something at language level, one feature that I think is essential is early definition checking of template functions.
    N1848 section 4 describes how that would work. Even this one I'm not sure if it can be implemented.

    There's also notion of nominal concepts which are explicitly opt in. They can be easily emulated with interfaces (on cpp2 side) and std::derived_from (on cpp side) so that's one more thing.

  4. Repository owner locked and limited conversation to collaborators on Aug 14, 2023
  5. converted this issue into a discussion #591 on Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions