Will there be standardization of scope guard/scope exit idioms?

爱⌒轻易说出口 提交于 2019-11-27 06:12:19

问题


Running a lambda on scope exit seems like such a basic thing, I would expect it to be standardized. Things like unique_ptr are better, when they apply, but I find there is an endless supply of "one-off" destructors are needed, especially when leveraging C-style libraries. Does anyone know if this is coming?


回答1:


n4189 is a proposal to add make_scope_exit wrappers, and other similar resource handlers, to the language. It is based off of the relatively famous scope_guard talk.

The most recent "current paper status" from LWG is in 2013, prior to the above date.

The contents of C++1z (hopefully C++17) are yet to be determined.

C++1z status for clang does not mention it. C++1z TS for clang does not mention it.

The paper itself contains an example implementation. I do not know what licensing terms it is under.




回答2:


It would appear that the current version of the scope exit paper, P0052, will be going into the Library Fundamentals v3, for likely adoption in the Post-C++17 standard.

In short, not gonna happen for C++17. Sorry.



来源:https://stackoverflow.com/questions/30405269/will-there-be-standardization-of-scope-guard-scope-exit-idioms

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