GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::bad_function_call - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. functional
  3. bad_function_call

最終更新日時: 2026年09月19日 21時31分51秒 (JST)
rotarymars が更新

履歴 編集

class
<functional>

std::bad_function_call(C++11)

namespace std {
  class bad_function_call : public exception;
}

概要

std::bad_function_callは、空のstd::functionオブジェクトに対してoperator()を呼び出した際に送出される例外クラスである。

注意: 空のstd::functionオブジェクトに対してstd::bind()を呼び出した結果をstd::functionオブジェクトに格納しても空にはならないが、実際にoperator()を呼ぶとstd::bad_function_call例外が送出される。

例

#include <iostream>
#include <functional>

int main()
{
  std::function<void()> f;

  try {
    f();
  }
  catch (std::bad_function_call& e) {
    std::cout << "bad function call" << std::endl;
  }
}

出力

bad function call

バージョン

言語

  • C++11

処理系

  • Clang: 9.0.1 ✅
  • GCC: 4.4 ✅
  • Visual C++: 2010 ✅
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.