I want to prevent certain functions from being called. Let's ignore the case of calling the function via a function pointer or something, and just concentrate on the case of direct function call. I can do this with = delete
. However, the diagnostic issued is not quite informative. I considered using static_assert
, with which you can supply a custom diagnostic message. I placed a static_assert(false, ...)
statement within the function body, hoping that it fires when the function is called. However, it turns out that the static_assert
fails even if the function is not called. Any suggestions?
Additional Note: The function is forbidden unconditionally. So, std::enable_if
does not apply here. The motivation for such a function is that I want to prevent certain use, which would otherwise compile fine with overload resolution. So I can't just remove the function. deprecated
is not what I want. I want a compilation error, not a warning.