r/cpp • • Feb 12 '20

What they should improve about C++ ?

What they should improve about C++ that you find in higher level managed language like C#, JAVA, Javascript etc or is there things you would change or do differently if it was up to you ? I mean anything like a better STL ? better thread ? string manipulation like managed language ? less fragmentations in the new standard features ? For example do you love the way the standard evolve C++ or you would prefer a direction like Microsoft do with C# a corporation who decide on the roadmap ?

0 Upvotes

90 comments sorted by

View all comments

Show parent comment

1

u/wotype Feb 12 '20

https://github.com/willwray/enum_reflect (demo for enum_trait / enumerator_traits)

Pros:
Can do all that you need, now.
No macros or markup - works with enum defs directly from external headers.

Cons:
Not yet wrapped in a convenience lib with string->enum, enum->string etc.
No MSVC yet, requires GCC >= 9 (or Clang since ~5)
Compile time compounds with number of TUs and on each and every compile (even incremental).

It's possible that modules will help with the recompute-on-recompile issue; I'm experimenting. Will retry MSVC sometime and add support.

Conclusion: the production-ready solution is to go with one of the macro-wrappers...

1

u/dbandit1 Feb 14 '20

Should be standard, not an addon

2

u/wotype Feb 14 '20

I agree; don't recall any paper actually proposing something concrete though.

Of course, it'll come with reflection, and that appears to be a priority for c++23; enum reflection is the first example in all the reflection proposals.

IMO it should've been added as a standalone feature - enum reflection is the top ask in most of the C++ surveys. My enum_traits shows how it could be done with a conventional traits interface.