Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Coding style conformance; typo fix

...

Code Block
bgColor#FFCCCC
langcpp
#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
bgColor#ccccff
langcpp
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
bgColor#ccccff
langcpp
#include <cstring>
 
struct S {
  int i : 10;
  int j;
};
 
void f(const S &s1) {
  S &s2;
  std::memcpy(&s2, &s1, sizeof(S));
}

...