#include <iostream>
#include <string>
#include <unordered_map>

struct A {
    int first;
    int second;
};

using member_ptr = int A::*;

using member_map = std::unordered_map<std::string, member_ptr>;

static member_map Amap = {
    {"first",  &A::first},
    {"second", &A::second}
};

int main()
{
    A a;
    a.*(Amap["first" ]) = 42;
    a.*(Amap["second"]) = 24;
    std::cout << a.first  << std::endl
              << a.second << std::endl;
    return 0;
}
