
On 11/12/2011 6:52 AM, Gennadiy Rozental wrote:
Lorenzo Caminiti<lorcaminiti<at> gmail.com> writes:
On Thu, Nov 10, 2011 at 6:43 PM, Gennadiy Rozental<rogeeff<at> gmail.com>> Hi,
Current implementation of subject macro have a very serious shortcoming - it does not work for empty __VA_ARGS__. After googling around a bit for some ideas I came up with the following alternative:
A while back there was a discussion about the possibility/impossibility to handle empty macro parameters using variadics:
http://lists.boost.org/Archives/boost/2011/02/177321.php
(Make sure to address the concerns expressed by Paul in the replies to the above thread.)
Frankly, I do not have time to read through the whole discussion. I am not a language lawyer, but for what it worth my version works on all compilers I have tried and looks to be perfectly legal (to me). I do know about one limitation. It's where __VA_ARGS__ ends with macro function which produces comma when evaluated. It's very rare case though and even if it's possible to implement solution that deals with it (look here: https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ ), I find the complication does not worth the trouble.
If Edward or Paul care to comment it might be easier for them to point to any shortcomings in my solution (if any).
I have already commented in a direct reply to your OP. I don't see how the link above gets around the function-like macro problem but I will study it to see what is involved.