Message from C, C++ discussions

December 2019

— Is there anymethod to iterate over a struc member


Struct A {
bool autenticated;
bool started;
bool enabled ;
A() {
autenticated = false;
started ⁼ false;
enabled = false;

— How to iterate over this class

— Using a loop or something like that

— Why should you?

— C++ does not support reflections, so there is no standard way to do it

— Because i want to initiate a struct of socket using sun_family = AF_UNIX

— And then do memset

— Sadly, reflection postponed from C++20, so there's still no standard way, but some approaches available:

Message permanent page

— I want to automate this initation

— Struct socketlist {
sockaddr_un masocket;
sockaddr_un psocket;
sockaddr_un vsocket;
sockaddr_un cisocket;
socketlist() {
masocket.sun_family = AF_UNIX;
psocket.sun_family = AF_UNIX;
vsocket.sun_family = AF_UNIX;
cisocket.sun_family = AF_UNIX;


Message permanent page

— I want to automate this process