std::bad_function_call
来自cppreference.com
< cpp | utility | functional
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <functional>
|
||
| class bad_function_call; |
(C++11 起) | |
std::bad_function_call is the type of the exception thrown by std::function::operator() if the function wrapper has no target.
目录 |
[编辑] 成员函数
| (constructor) |
bad_function_call() (公共成员函数) |
std::bad_function_call::bad_function_call()
| bad_function_call(); |
||
Constructs a new instance of std::bad_function_call.
Parameters
(none)
Exceptions
Inherited from std::exception
Member functions
| [虚拟的] </ SPAN></div></div>
|
解构异常对象 Original: destructs the exception object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (虚拟公有成员函数of std::exception)
|
| [虚拟的] </ SPAN></div></div>
|
返回一个说明字符串 Original: returns an explanatory string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (虚拟公有成员函数of std::exception)
|
</div>
[编辑] 为例
#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'; } }
Output:
bad function call
[编辑] 另请参阅
| (C++11) |
包装任何类型的可调用对象与指定的函数调用签名 Original: wraps callable object of any type with specified function call signature The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类模板) |
