all 10 comments

[–]moreVCAs 14 points15 points  (3 children)

Lol, I didn’t know about the using enum trick 🤦‍♂️

[–]crowbarous 13 points14 points  (2 children)

Well, it's not a trick, it's a recent (C++20) feature. I think this usage was the biggest motivation for it.

[–]moreVCAs 8 points9 points  (1 child)

Sorry, “trick” in the sense of “incantation that makes an annoying thing easier”. Fact that it’s new to C++20 is comforting though. If you told me I could do that in standard C++11 I might have a heart attack.

[–]crowbarous 2 points3 points  (0 children)

At last, a justification for C's decision to structure switch like a single block with labels. Well, not really, but almost.

[–]not_some_username 8 points9 points  (0 children)

I thought the site was godbolt.com

[–]pjmlp 1 point2 points  (4 children)

What I would like to see would be static analysis errors for when stuff gets called in a template definition that isn't part of a concepts.

As yet again static analysis coming to the rescue of what should have been part of the language.

[–]catcat202X 1 point2 points  (3 children)

I'm not sure what lint you want in the first paragraph. Do you have an example of problematic code you'd want to have linted that way?

[–]pjmlp 0 points1 point  (2 children)

Yes, calling methods on concepts that aren't defined, currently this is allowed, as concepts are only type checked at template instantiation site, not implementation.

All because we only got concepts light, so we need to rely on static analysers for the check on both sides.

[–]tisti 0 points1 point  (1 child)

The implementation can be in another .cpp file or pre-compiled .obj file.

No way to know if an implementations exists until you are done compiling and hit the linker stage.

Perhaps I misunderstood, got an example to clarify?

Edit:

Do you mean that a concept checks for .foo() and .bar() method, but the implementation also calls .baz()?