std::function::target_type(3)
β¨ NAME β¨
okay bestie, welcome to the std::function::target_type(3) page from the C++ Standard Libary π
this is the manual for std::function::target_type - std::function::target_type, and yes, the name is literally the name. no notes. iconic.
πΈ Synopsis πΈ
this is the signature, and she has been serving since C++11:
const std::type_info& target_type() const noexcept; (since C++11)
she returns the type of the stored function. periodt.
π Parameters π
bestie. there are none. literally (none). the parameter list is empty and living her best life.
π¦ Return value π¦
if the stored function has type T, you get typeid(T); otherwise you get typeid(void). that's the whole situation. π
π₯ Example π₯
run this code, it's right here:
// Run this code
#include <functional>
#include <iostream>
int f(int a) { return -a; }
void g(double) {}
int main()
{
// fn1 and fn2 have the same type, but their targets do not
std::function<int(int)> fn1(f),
fn2([](int a) {return -a;});
std::cout << fn1.target_type().name() << '\n'
<< fn2.target_type().name() << '\n';
// since C++17 deduction guides (CTAD) can avail
std::cout << std::function{g}.target_type().name() << '\n';
}
π Possible output π
your output could look like this:
PFiiE
Z4mainEUliE_
PFvdE
π See also π
targetβ obtains a pointer to the stored target (public member function)typeidβ Queries information of a type, returning astd::type_infoobject representing the type.type_infoβ This is the class returned by thetypeidoperator. contains some type's information, generated by the implementation. (class)
catch you later bestie π«Ά this little page came from http://cppreference.com, dated 2024.06.10, for std::function::target_type(3). mwah π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms