Will Concepts replace SFINAE?
Asked Answered
M

1

9

Concepts likely to be in the C++ standard (C++17, or maybe C++20).

So I wonder if this new feature can completely replace SFINAE, or it's just a small version of SFINAE with nice error reports and type checking.

Are there any cases when SFINAE is the only choice instead of using Concepts?

Monsoon answered 25/1, 2015 at 4:8 Comment(7)
Maybe in the sense for “replaced” goto?Stitch
That would be very nice.Monsoon
I don't see expression SFINAE being phased out for basic things that don't require full fledged concepts.Envelopment
@Envelopment Could you give a simple example?Monsoon
What do you mean with "replace SFINAE"? Do you mean that substitution failure would be an error? That would break a lot of existing code. What's the reason for doing that?Cladoceran
No, I mean that in new code I don't need to use SFINAE anymore.Monsoon
@DDrmmr the question is about the techniques that dispatch between template specializations/overloads using SFINAE, not SFINAE itself I reckon.Dugas
G
10

With concepts taking shape and being implemented in compilers (currently only gcc >= 6.1 with option -fconcepts), it appears that they can do everything that you could have done using SFINAE only much better (much clearer expression of intent and producing concise error messages), and much more (such as abbreviated templates).

So the simple answer is YES.

Greggrega answered 6/2, 2017 at 16:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.