SBRM/RAII for std::va_list/va_start()/va_end use

寵の児 提交于 2019-12-03 13:30:50

Unfortunately, no. The specification of va_start and va_end requires that:

Each invocation of the va_start and va_copy macros shall be matched by a corresponding invocation of the va_end macro in the same function.

Therefore, va_end must be in the variadic function itself, not a class destructor.

One of possible implementations assumes std::va_list = char* and va_end() is just setting that pointer to null. Of cause, it can be called outside of function. But I'm not sure, that it will works similar on other platforms.

Better to wrap this functions with a class.

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