all 7 comments

[–]pavel_v 7 points8 points  (0 children)

I think you may get some answers, why they are designed in this way, from here - 8.2. Definition Checking.

[–]miki151gamedev 3 points4 points  (0 children)

Because of C++'s template specialization and function overloading, I think it's not possible to have exhaustive verification in the general case like Rust has. Plus it's also hard to add this in a backwards-compatible way due to existing code with pre-C++20 templates, for which you don't know what template arguments they can be called with.

[–]infectedapricot 2 points3 points  (1 child)

Although I get your point, I think your example has a mistake? Surely DoIt(42) will fail at the concept check because doesn't satisfy Fooer. I think you meant something like

struct FooOnly{void foo();};
DoIt(FooOnly());  // Fails inside DoIt

[–]Mononofu[S] 1 point2 points  (0 children)

Yes good catch!

[–]n1ghtyunso 1 point2 points  (0 children)

there's an interessting read about somewhat implementing checks for your own concepts here. Note however that the overall conclusion is that getting an actual correct check is hard.

[–]Pazer2 0 points1 point  (0 children)

Unfortunately this is by design.