std::function_ref
的推導指南
來自 cppreference.com
< cpp | 工具庫 | 函式物件 | function ref
定義於標頭檔案 <functional> |
||
template< class F > function_ref( F* ) -> function_ref<F>; |
(1) | (C++26 起) |
template< auto f > function_ref( std::nontype_t<f> ) -> function_ref</*見下文*/>; |
(2) | (C++26 起) |
template< auto f, class T > function_ref( std::nontype_t<f>, T&& ) -> function_ref</*見下文*/>; |
(3) | (C++26 起) |
2) 令型別 F 為 std::remove_pointer_t<decltype(f)>。僅當 std::is_function_v<F> 為 true 時,此過載才參與過載決議。推導的型別為 std::function_ref<F>。
3) 令型別 F 為 decltype(f)。此過載僅在以下情況參與過載決議:
- F 的形式為 R(G::*)(A...) noexcept(E)(可選 cv-qualified,可選 noexcept,可選左值引用 qualified),其中 G 為某個型別,或者
- F 的形式為 M G::*,其中 G 為某個型別,M 為某個物件型別;在這種情況下,令 R 為 std::invoke_result_t<F, T&>,A... 為一個空包,E 為 false,或者
- F 的形式為 R(*)(G, A...) noexcept(E),其中 G 為某個型別。
- 推導的型別為 std::function_ref<R(A...) noexcept(E)>。
[編輯] 示例
本節不完整 原因:無示例 |