What does it mean to “poison a function” in C++?

前端 未结 2 1634
谎友^
谎友^ 2020-12-04 11:47

At the very end of Scott Schurr\'s talk \"Introducing constexpr\" at CppCon, he asks \"Is there a way to poison a function\"? He then explains that this can be done (albeit

2条回答
  •  佛祖请我去吃肉
    2020-12-04 12:25

    'Poisoning' an identifier means that any reference to the identifier after the 'poisoning' is a hard compiler error. This technique may be used, for instance, for hard deprecation (function IS deprecated, never use it!).

    In GCC traditionally there was a pragma for this: #pragma GCC poison.

提交回复
热议问题