Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/utility/functional/bad function call"

From cppreference.com
< cpp‎ | utility‎ | functional
m (Text replace - "{{example cpp" to "{{example")
m (Text replace - "cpp/error/exception" to "cpp/error")
Line 16: Line 16:
 
{{dcl list end}}
 
{{dcl list end}}
  
{{cpp/error/exception/exception/inherit}}
+
{{cpp/error/exception/inherit}}
  
 
===Example===
 
===Example===

Revision as of 00:40, 29 April 2012

Template:cpp/utility/functional/sidebar 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 : public std::exception;
</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 function::operator() if the function wrapper has no target.

Contents

Member functions

constructs the bad_function_call object
(public member function)
[virtual]
returns the explanatory string
(virtual public member function)

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]