refl-cpp
Magic Enum C++
Our great sponsors
refl-cpp | Magic Enum C++ | |
---|---|---|
3 | 44 | |
986 | 4,403 | |
- | - | |
0.0 | 8.1 | |
over 1 year ago | 14 days ago | |
C++ | C++ | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
refl-cpp
-
Out of bounds memory access in V8 in Google Chrome prior to 120.0.6099.224
You'd be surprised how much friction you'd have for C++ reflection. First, since it's a custom build step, you can do a mix of custom code gen and C++ constexpr/consteval for static reflection. Here's a header-only implementation for adding compile time reflection purely within the language [1]. And v8 already does dynamic code gen as part of its build process (to generate the snapshot to speedup instantiation of the isolate). Dynamic reflection is a must since JS is a dynamic language with reflection support.
Now of course, I don't know the specific details of reflection needed for the abstractions you reference and clearly V8 is still doing some amount of manual IR generation, so it's possible it would be a substantial investment to actually retrofit those techniques into v8. One would have to do a careful analysis of historical security exploits & specific techniques and their ability to prevent to figure out if it's worth adding those abstractions (especially since there is a potential performance tradeoff as you mention). As I said, I think there's insufficient research in this area to establish a compelling body of best practices (not to take away from the contributions of the GraalJS team to this space).
[1] https://github.com/veselink1/refl-cpp
-
C++ Reflection for Component Serialization and Inspection
I’ve been using https://github.com/veselink1/refl-cpp for my recent project where i needed reflections, especially for serialization. Cant wait for c++48 and reflections in standard
- Show HN: Static reflection for C++17 (enumeration, attributes, proxies, ...)
Magic Enum C++
-
What C++ library do you wish existed but hasn’t been created yet?
I'm not sure this is quite what you're asking for, but this library has been super helpful to me in the past : https://github.com/Neargye/magic_enum
- Usable Magic Enums for C++
-
Fully Permissive License C++ Logger For Embedded System
Also, a shoutout to Magic Enum: https://github.com/Neargye/magic_enum
- Favorite Ways of Stringifying Enums
-
enum_name (yet another enum to/from string conversion utility >=C++11)
What does this have to offer over magic_enum?
-
quill v2.7.0 released - Asynchronous Low Latency C++ Logging Library
But it's a hack, and I prefer not to use hacks in production, because of their significant limitations:
-
Enums print numbers instead of words
You can either write a to string(view) function for your enum or use https://github.com/Neargye/magic_enum
-
Enums with methods
Why reinvent the wheel? magic_enum
-
Error: Boost bimap can't convert const CompatibleKey to Key&
Also if you want to convert enum members to string representation I suggest you just use magic_enum instead, much smaller dependency.
-
Macro to write enum and converter from and to string
Magic Enum provides that.
What are some alternatives?
svector - Compact SVO optimized vector for C++17 or higher
Nameof C++ - Nameof operator for modern C++, simply obtain the name of a variable, type, function, macro, and enum
entt - Gaming meets modern C++ - a fast and reliable entity component system (ECS) and much more
Protobuf - Protocol Buffers - Google's data interchange format
crunchy-bytes - C++ 17 Schema Serialization Library
cereal - A C++11 library for serialization
json - JSON for Modern C++
Boost.Serialization - Boost.org serialization module
scope_guard - A modern C++ scope guard that is easy to use but hard to misuse.
FlatBuffers - FlatBuffers: Memory Efficient Serialization Library
BLIB - Small organized collection of common code I have accumulated over the years that has amassed into a proper 2d game engine
pfr - std::tuple like methods for user defined types without any macro or boilerplate code