P
pete
Keith said:[...]Jack Klein said:No, there is no such operator.
There is no such thing in C, nor is there any need for such a thing in
C.
Obviously there's no absolute need for it, since we've gotten along
for many years without it. But it could be useful in some contexts.
For example, you could use it to write a type-generic swap macro,
something like (untested code follows):
#define SWAP(a, b) do { \
typeof(a) tmp = a; b = a; a = tmp; \
} while(0)
I write that, this way:
#define SWAP(A, B, T) \
((void)(*(T) = *(A), *(A) = *(B), *(B) = *(T)))
I think it's bad style to define objects inside of a macro.