C Preprocessor, Macro “Overloading”

天涯浪子 提交于 2019-11-27 14:53:04

To answer your question 2 first. Yes, with variadic macros it is also possible to detect an empty argument list. The explanation is a bit lengthy, I have written it up here. It should be relatively easy to combine this approach with the boost macros that you are using.

For your question 1, yes this is also possible. Boost has some iterator macros that come close to this, I think, but they look a bit scary to use. If I understand correctly you have to use something like nested lists (a, (b, (c,d))), not too convenient.

(I wrote a set of macros that can achieve this more directly, but unfortunately the package is not yet ready for release. Contact me in private if you are really interested in it.)

Edit: The P99 package is published in the mean time and contains a lot of stuff over macro "overloading" and type generic macros.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!