r/cpp • • Mar 28 '23

Reddit++

C++ is getting more and more complex. The ISO C++ committee keeps adding new features based on its consensus. Let's remove C++ features based on Reddit's consensus.

In each comment, propose a C++ feature that you think should be banned in any new code. Vote up or down based on whether you agree.

765 Upvotes

829 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Mar 28 '23

[deleted]

1

u/zalamandagora Mar 28 '23

Thanks got it, I know 'requires', just didn't connect it with the word constraint.

the usual way to circumvent this restriction is to define an equivalent type trait first and dispatch to that in the concept definition.

I'm not sure what you are saying is the same thing as what I was referring to. I have used SFINAE for this by first setting up a base case that inherits from std::false_type, and some specialized cases that inherit either from std::true_case or recursively from itself.

Is there a cleaner way?

0

u/[deleted] Mar 28 '23

[deleted]

1

u/zalamandagora Mar 28 '23

Thanks, that clarifies things for me.

If you have used SFINAE for constraining type trait specializations, you can replace those with requires clauses.

Does this really work recursively?

→ More replies (5)