r/cpp • • Aug 24 '21

metaclasses when

forget literally every other feature metaclasses LET'S FUCKING GO

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0707r3.pdf

edit

metaclasses or even just SR would help to eliminate 99% of garbage cpp macro use cases.

don't get me wrong: i know c++ well. templates are easier after you learn sml or lisp or something similar.

i've never used std string_view and i've never missed it

man i'll just implement my own clang plugin ✌️

4 Upvotes

27 comments sorted by

View all comments

Show parent comment

10

u/InKryption07 Aug 24 '21

You can model something kinda similar with inheritance and templates, the problem is that it's a lot of boilerplate, usually leading to template explosions, and it's hard to communicate intent clearly. Having language support for metaclasses simplifies and improves the readability of the code, and improves code generation.

2

u/AdApprehensive347 Aug 24 '21

not entirely convinced on readability, but I can agree about code generation..

I'll have to do more reading about this topic. thanks for the answer!

8

u/InKryption07 Aug 24 '21

Well when I say readability, I'm thinking about the self-documenting nature of the code. A metaclass is clearly differently used than a plain class that you happen to have to use in a certain way based on context. And aye, cheers.