5 ms·
(Edit: fixed formatting) Revolting? I think that's a pretty good, if complex, example of "pushing the limits". IMHO, the label "revolting" is reserved for code
by DCoder 16y ago
(Edit: fixed formatting)
Revolting? I think that's a pretty good, if complex, example of "pushing the limits". IMHO, the label "revolting" is reserved for code like this:
Derived() : Base() {
THISCALL(0x535AA0);
*(DWORD*)this = 0x7E1AF4;
}
That's the kind of code I get to write in my hobby project.
- barrkel 16y agoIt's using the type system to encode an arithmetic expression, with unique types for every distinct subtree; and then using statically-dispatched calls to inlined methods to get the compiler to embed the tree in-place, so that the optimizer's constant folding can evaluate the tree. The amount of code and data that's being shifted around and manipulated inside the compiler to generate a rather trivial end effect is what's offensive to me. If C++ were slightly more expressive, the technique would be unnecessary; but some C++ acolytes actually extol these kinds of techniques as a feature!
- jheriko 16y agoThe technique is unnecessary, regardless as to C++ - its just a different way to write code.