首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::bad_function_call

Defined in header <functional>

?

?

class bad_function_call;

?

(since C++11)

std::bad_function_call引发的异常的类型。std::function::operator()如果函数包装器没有目标。

二次

二次

继承图

成员函数

(constructor)

bad_function_call() (public member function)

STD:不好[医]功能[医]呼叫::坏[医]功能[医]拨打%28%29

bad_function_call();

?

?

构造一个新的实例。std::bad_function_call...

参数

%280%29

例外

noexcept规格:

noexcept

继承自STD:例外

成员函数

(destructor) virtual

destructs the exception object (virtual public member function of std::exception)

what virtual

returns an explanatory string (virtual public member function of std::exception)

二次

代码语言:javascript
复制
#include <iostream>
#include <functional>
 
int main()
{
    std::function<int()> f = nullptr;
    try {
        f();
    } catch(const std::bad_function_call& e) {
        std::cout << e.what() << '\n';
    }
}

二次

可能的产出:

二次

代码语言:javascript
复制
bad function call

二次

另见

function (C++11)

wraps callable object of any type with specified function call signature (class template)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com