C++ Exception Library - bad_function_call


Advertisements

Description

This an exception thrown on bad call.

Declaration

Following is the declaration for std::bad_function_call.

class bad_function_call;

C++11

class bad_function_call;

Parameters

none

Return Value

none

Exceptions

No-throw guarantee − no members throw exceptions.

Example

In below example for std::bad_function_call.

#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';
   }
}

The sample output should be like this −

bad_function_call
exception.htm
Advertisements