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::function::target_type - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. functional
  3. function
  4. target_type

最終更新日時: 2026年09月16日 21時49分06秒 (JST)
rotarymars が更新

履歴 編集

function
<functional>

std::function::target_type(C++11)

const std::type_info& target_type() const noexcept;

概要

元となる関数の型情報を取得する。

戻り値

呼び出す関数を持っていれば、その関数の型を表すtype_infoオブジェクトを返す。呼び出す関数を持っていなければ、typeid(void)を返す。

例

#include <iostream>
#include <functional>

struct ident {
  int operator()(int x) const
  { return x; }
};

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

  if (f.target_type() == typeid(ident)) {
    std::cout << "f has ident" << std::endl;
  }
  else {
    std::cout << "f doesn't have ident" << std::endl;
  }
}

出力

f has ident

バージョン

言語

  • C++11

処理系

  • Clang: 3.0 ✅
  • GCC: 4.3.6 ✅
  • Visual C++: ??
You are visitor 01402520 — 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.