2 ms·
Are both sides of the ternary operator always evaluated? Otherwise you could even use this monstrosity: output_buffer[pos++] = (input1[pos1] <= input1[pos
by contravariant 5y ago
Are both sides of the ternary operator always evaluated?
Otherwise you could even use this monstrosity:
output_buffer[pos++] = (input1[pos1] <= input1[pos2]) ? input1[pos1++] : input2[pos2++];
- gpderetta 5y agoIt would work, but the point is not golfing but convincing the compiler to generate a cmov. The branches of your ?: have side effects, so it won't be easier for the compiler to optimize than a normal if.
- contravariant 5y agoHonestly I was mostly curious if it would even work, because it sure looks like it ought not to.