什么原因std :: bad_function_call? [英] What causes std::bad_function_call?

查看:730
本文介绍了什么原因std :: bad_function_call?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过几个 问题,指的是 std :: bad_function_call exception ,但是还没有找到任何由谷歌关于什么导致这个例外。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆