class
<functional>
std::bad_function_call
Exception thrown on bad call
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
// bad_function_call example
#include <iostream> // std::cout
#include <functional> // std::function, std::plus, std::bad_function_call
int main () {
std::function<int(int,int)> foo = std::plus<int>();
std::function<int(int,int)> bar;
try {
std::cout << foo(10,20) << '\n';
std::cout << bar(10,20) << '\n';
}
catch (std::bad_function_call& e)
{
std::cout << "ERROR: Bad function call\n";
}
return 0;
}
| |
Output:
30
ERROR: Bad function call
|
Exception safety
No-throw guarantee: no members throw exceptions.
See also
- exception
- Standard exception class (class
)
- function
- Function wrapper (class template
)