Код: Выделить всё
#include
struct Foo {
uint64_t x;
};
void test(Foo& f, uint64_t Foo::* p) {
(f.*p) = 5;
}
Код: Выделить всё
#include
struct Foo {
uint64_t x;
};
void test32(Foo& f, uint32_t Foo::* p) {
(f.*p) = 5;
}
void test(Foo& f, uint64_t Foo::* p) {
test32(f, reinterpret_cast(p) + 1);
}
Код: Выделить всё
error: invalid operands of types 'uint32_t Foo::*' {aka 'unsigned int Foo::*'} and 'int' to binary 'operator+'
(И да, я знаю, что это кажется плохой идеей. Пожалуйста, нет " «ты не должен этого делать» (комментарии).)
Подробнее здесь: https://stackoverflow.com/questions/784 ... -to-member