...
| Code Block | ||||
|---|---|---|---|---|
| ||||
#include <cstring>
struct S {
unsigned char buff_typebuffType;
int size;
};
void f(const S &s1, const S &s2) {
if (!std::memcmp(&s1, &s2, sizeof(S))) {
// ...
}
} |
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
struct S {
unsigned char buff_typebuffType;
int size;
friend bool operator==(const S &LHS, const S &RHS) {
return LHS.buff_typebuffType == RHS.buff_typebuffType &&
LHS.size == RHS.size;
}
};
void f(const S &s1, const S &s2) {
if (s1 == s2) {
// ...
}
} |
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
#include <cstring>
struct S {
int i : 10;
int j;
};
void f(const S &s1) {
S &s2;
std::memcpy(&s2, &s1, sizeof(S));
} |
...