python (65.1k questions)
javascript (44.2k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (12.9k questions)
Has atomic type-punning through unions defined behaviour?
Type-punning through unions has defined behaviour in C:
typedef union
{
uint32_t i;
float f;
} MyUnion;
MyUnion u;
u.f = 4.2;
print("%"PRIu32, u.i); // defined behaviour
Given via ...
dyp
Votes: 0
Answers: 1
C++ Union Array differs in 32/64 bits
My code:
union FIELD {
int n;
char c;
const char *s;
FIELD(){}
FIELD(int v){ n = v; }
FIELD(char v){ c = v; }
FIELD(const char* v){ s = v; }
};
struct SF {
const char*...
唐太宗
Votes: 0
Answers: 1
Appending to vector of union
I have a union, defined like so:
union CellType {
std::string str;
int i;
double d;
Money<2> m; // Custom class for fixed-decimal math.
};
Then, I have a vector of such unions....
HiddenWindshield
Votes: 0
Answers: 2