Partager via


bad_function_call Class

Reports a bad function call.

class bad_function_call
    : public std::exception {
    };

Remarks

The class describes an exception thrown to indicate that a call to operator() on a function Class object failed because the object was empty.

Example

 

// std_tr1__functional__bad_function_call.cpp 
// compile with: /EHsc 
#include <functional> 
#include <iostream> 
 
typedef double (Fd)(double); 
typedef std::function<Fd> Myfunc; 
 
double square(double x) 
    { 
    return (x * x); 
    } 
 
int main() 
    { 
    Myfunc fd0(square); 
    std::cout << "x * x == " << fd0(3) << std::endl; 
 
    try 
        { 
        Myfunc fd1; 
        std::cout << fd1(3) << std::endl; 
        } 
    catch (const std::bad_function_call&) 
        { 
        std::cout << "bad function call" << std::endl; 
        } 
    catch (...) 
        { 
        std::cout << "unknown exception" << std::endl; 
        } 
 
    return (0); 
    } 
 
x * x == 9
bad function call

Requirements

Header: <functional>

Namespace: std