Magic Enum C++ VS pfr

Compare Magic Enum C++ vs pfr and see what are their differences.

Magic Enum C++

Static reflection for enums (to string, from string, iteration) for modern C++, work with any enum type without any macro or boilerplate code (by Neargye)

pfr

std::tuple like methods for user defined types without any macro or boilerplate code (by boostorg)
Our great sponsors
  • SonarCloud - Analyze your C and C++ projects with just one click.
  • Mergify - Updating dependencies is time-consuming.
  • InfluxDB - Collect and Analyze Billions of Data Points in Real Time
Magic Enum C++ pfr
44 3
3,918 1,181
- 2.6%
0.0 0.0
6 days ago 4 days ago
C++ C++
MIT License Boost Software License 1.0
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
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.

Magic Enum C++

Posts with mentions or reviews of Magic Enum C++. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-07-08.

pfr

Posts with mentions or reviews of pfr. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-03-23.
  • Minimum viable declarative GUI in C++
    3 projects | /r/cpp | 23 Mar 2022
    The code is relatively short and can be groked with a few coffees: https://github.com/boostorg/pfr/tree/develop/include/boost/pfr ; if you're using C++17 it uses a binary search (https://github.com/boostorg/pfr/blob/develop/include/boost/pfr/detail/fields_count.hpp) to count the number of fields in a struct, by starting by the observation that a likely majorant on the number of fields in a struct is sizeof(the struct) * CHAR_BIT, assuming not too many [[no_unique_address]] tomfooleries. Then once this count is known it's possible to simply map them as a tuple through sheer brute force and destructuring: https://github.com/boostorg/pfr/blob/develop/include/boost/pfr/detail/core17_generated.hpp
  • The Serde Rust Framework
    14 projects | news.ycombinator.com | 14 Oct 2021
    I wonder if the c++ approach of boost.pfr would be portable to rust ? It allows reflection on aggregates without needing to annotate anything: https://github.com/boostorg/pfr
  • Counting the number of fields in an aggregate in C++20
    2 projects | /r/cpp | 14 Mar 2021
    It is an 'interesting' meta-programming problem though (wasted many weeks on it myself, fixed a small gcc bug - a 'uniform init' edge case and filed an issue with magic_get Reflecting array members of aggregate structs).

What are some alternatives?

When comparing Magic Enum C++ and pfr you can also consider the following projects:

Nameof C++ - Nameof operator for modern C++, simply obtain the name of a variable, type, function, macro, and enum

Protobuf - Protocol Buffers - Google's data interchange format

cereal - A C++11 library for serialization

FlatBuffers - FlatBuffers: Memory Efficient Serialization Library

Boost.Serialization - Boost.org serialization module

rttr - C++ Reflection Library

Bitsery - Your binary serialization library

wise_enum - A reflective enum implementation for C++

protozero - Minimalist protocol buffer decoder and encoder in C++

cppbor - An implementation of cbor using C++ 17 variants

MessagePack - MessagePack implementation for C and C++ / msgpack.org[C/C++]

tomlplusplus - Header-only TOML config file parser and serializer for C++17.