std::function::target
时间: 2023-09-04 17:12:46 浏览: 188
std::function::target是一个成员函数,用于返回存储在std::function对象中的可调用对象的指针。如果std::function对象没有目标,即为空,调用target会返回nullptr。 这个函数的返回类型取决于可调用对象的类型。在示例中,通过调用fn1.target<std::_Bind<int (foo::*(foo *, std::_Placeholder<1>)(int)>>(),可以将fn1的目标类型转换为std::_Bind<int (foo::*(foo *, std::_Placeholder<1>)(int)>的指针。如果转换成功,指针将指向可调用对象的地址,否则返回nullptr。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [std::function](https://blog.csdn.net/qq_41278986/article/details/117479799)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [c++比较std::function,以及target()的坑](https://blog.csdn.net/qq_37105120/article/details/119772863)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文