←back to thread

196 points svlasov | 2 comments | | HN request time: 0s | source
Show context
TillE ◴[] No.40851335[source]
Finally. I think there have been proposals since C++17 at least, and all I really wanted is for them to solve the common problem of basic static reflection for enums (without hacks like magic_enum uses).
replies(1): >>40851454 #
jjmarr ◴[] No.40851454[source]
magic_enum is killing my build time with endless template instantiations. Is this going to be faster?
replies(3): >>40851746 #>>40853037 #>>40871158 #
1. leni536 ◴[] No.40851746[source]
magic_enum works by walking all possible enumeration values from one-by-one in a wide range at compile time, instantiating a function template for each one so it can extract the __PRETTY_FUNCTION__ name, which is very slow. The C++26 feature just directly returns the vector of the named enumerators in one go, so it should be way faster.

They have a reference implementation on godbolt under clang, so you can play around with that. I did not try it yet.

replies(1): >>40852230 #
2. jjmarr ◴[] No.40852230[source]
Wow. I'm trying to make some of these template instantiations explicit on a large project I'm on as magic_enum is one of the largest contributors to our build-time.

It's nice to know I can just transition to C++26 to fix this.