什么原因导致std :: bad_function_call? [英] What causes std::bad_function_call?
本文介绍了什么原因导致std :: bad_function_call?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看过很少 问题,引用 std :: bad_function_call
exception < a>,但是无法通过Googling找到导致此异常的原因。
I've seen a few questions that refer to the std::bad_function_call
exception, but haven't been able to find out any by Googling about what causes this exception.
什么样的行为应该导致此异常?
What kind of behavior is supposed to cause this exception? Can you give me minimal examples that don't have other semantic problems also going on?
推荐答案
当然,最简单的例子是:尝试调用 std :: function
为空。
Sure- the easiest is where you try to call a std::function
that's empty.
int main() {
std::function<int()> intfunc;
int x = intfunc(); // BAD
}
这篇关于什么原因导致std :: bad_function_call?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文