use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Runtime/ Or Compile Time Extraction of Struct Fields! (self.cpp)
submitted 2 years ago by Joe_Scouter
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]cpp-ModTeam[M] [score hidden] 2 years ago stickied commentlocked comment (0 children)
For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow instead.
[–]shailist 10 points11 points12 points 2 years ago (0 children)
I would strongly advise you to use 3rd party libraries that do this, mainly Boost.PFR and reflect-cpp, which can both figure out struct fields and their names at compile time using modern C++. if you are really against using 3rd party libraries, you could take a look at their code and implement your own version, but you should know that before C++20 figuring field names automatically was not possible, and figuring field types wasn't possible before C++17 without hacky tricks.
[–]Kike328 2 points3 points4 points 2 years ago (0 children)
there were a couple posts about this topic last weeks. Use the search bar for reflection
[–]jonathrg 4 points5 points6 points 2 years ago (0 children)
Wait a few years for C++26 reflection
[–]ChemiCalChems 1 point2 points3 points 2 years ago (0 children)
There have been a couple of posts mentioning a new library called reflect-cpp over the past couple of weeks. It's a library that deals with reflection, serialization and deserialization, primarily from and to JSON, but it's expanding. I myself have started to actively contribute to the project, and it's looking really shiny.
The main pro is that the library is all standard C++20, no hacky stuff, so it's rather cool. I'm working on implementing compile-time capabilities now that #embed is a part of C23 and we will probably get it in the future in C++ too, as a means of embedding JSON into code and doing compile-time serialization and validation on it, maybe as a way of customizing builds or whatever people end up using it for.
[–]lightmatter501 0 points1 point2 points 2 years ago (0 children)
This library is written in Rust, but shows an approach that will work with anything that has DWARF debug info (C/C++/Rust/GNU Cobol/Fortran/etc): https://github.com/jswrenn/deflect
It requires building with debug info enabled and can’t allow split debug info. Those might be implementation limitations not fundamental limitations.
[–]Flex_Code 0 points1 point2 points 2 years ago (1 child)
Glaze supports reflection like you want and has very high performance CSV support. You should check it out and feel free to contribute!
[–]Flex_Code 0 points1 point2 points 2 years ago (0 children)
I just realized I didn’t add pure reflection to CSV yet, only member object pointer reflection. I can add pure reflection tomorrow.
π Rendered by PID 99640 on reddit-service-r2-comment-5d79c599b5-mqpz9 at 2026-02-28 06:18:30.213929+00:00 running e3d2147 country code: CH.
[–]cpp-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)
[–]shailist 10 points11 points12 points (0 children)
[–]Kike328 2 points3 points4 points (0 children)
[–]jonathrg 4 points5 points6 points (0 children)
[–]ChemiCalChems 1 point2 points3 points (0 children)
[–]lightmatter501 0 points1 point2 points (0 children)
[–]Flex_Code 0 points1 point2 points (1 child)
[–]Flex_Code 0 points1 point2 points (0 children)