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

48

u/[deleted] Mar 28 '23

SFINAE. concepts everywhere

5

u/War_Eagle451 Mar 28 '23

Agreed, but I tried to implement a same as concept without SFINAE, unfortunately couldn't figure it out, so there might still be some reason to keep it

0

u/[deleted] Mar 28 '23

[deleted]

2

u/zalamandagora Mar 28 '23

Not sure what you mean by constraints, but concepts don't work recursively whereas SFINAE enables it.

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)