bad_function_call 클래스
Reports a bad function call.
class bad_function_call
: public std::exception {
};
설명
The class describes an exception thrown to indicate that a call to operator() on a function 클래스 object failed because the object was empty.
예제
// 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);
}
요구 사항
헤더: <기능>
네임스페이스: std