Namespaces
Variants
Views
Actions

std::bad_function_call

From cppreference.com
< cpp‎ | utility‎ | functional
Revision as of 14:31, 2 November 2012 by P12bot (Talk | contribs)

 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
Function objects
Function wrappers
(C++11)
(C++11)
bad_function_call
(C++11)
Function invocation
(C++17)(C++23)
Identity function object
(C++20)
Transparent operator wrappers
(C++14)
(C++14)
(C++14)
(C++14)  
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)

Old binders and adaptors
(until C++17*)
(until C++17*)
(until C++17*)
(until C++17*)  
(until C++17*)
(until C++17*)(until C++17*)(until C++17*)(until C++17*)
(until C++20*)
(until C++20*)
(until C++17*)(until C++17*)
(until C++17*)(until C++17*)

(until C++17*)
(until C++17*)(until C++17*)(until C++17*)(until C++17*)
(until C++20*)
(until C++20*)
 

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <functional>
</td>

<td></td> <td></td> </tr> <tr class="t-dcl ">

<td >
class bad_function_call;
</td>

<td class="t-dcl-nopad"> </td> <td > (since C++11) </td> </tr> Template:ddcl list end

std::bad_function_call is the type of the exception thrown by std::function::operator() if the function wrapper has no target.

cpp/error/exceptionstd-bad function call-inheritance.svg

Inheritance diagram

Contents

Member functions

(constructor)
bad_function_call()
(public member function)

std::bad_function_call::bad_function_call()

bad_function_call();

Constructs a new instance of std::bad_function_call.

Parameters

(none)

Exceptions

noexcept specification:  
noexcept
  

Inherited from std::exception

Member functions

[virtual]
destroys the exception object
(virtual public member function of std::exception) [edit]
[virtual]
returns an explanatory string
(virtual public member function of std::exception) [edit]

Example

#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

See also

(C++11)
copyable wrapper of any copy constructible callable object
(class template) [edit]