##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::bad_function_call

From cppreference.com
< cpp‎ | utility‎ | functional

Defined in header `<functional>` |  |
class bad_function_call; |  | (since C++11)

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

Inheritance diagram

### [edit] 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

(destructor) [virtual] | destructs the exception object (virtual public member function of `std::exception`) [edit]
what [virtual] | returns an explanatory string (virtual public member function of `std::exception`) [edit]

### [edit] Example

Run this code

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

Possible output:

    bad function call

### [edit] See also

function (C++11) | wraps callable object of any type with specified function call signature (class template) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/utility/functional/bad_function_call&oldid=91745"
Category:

- unconditionally noexcept

Hidden categories:

- Pages with unreviewed unconditional noexcept template
- Pages with unreviewed noexcept template