指引推导 (deduction guides) 用于 std::function_ref
来自 zh.cppreference.net
| 定义于头文件 <functional>
|
||
template< class F >
function_ref( F* ) -> function_ref<F>;
|
(1) | (自 C++26) |
template< auto f >
function_ref( std::nontype_t<f> ) -> function_ref</*see below*/>;
|
(2) | (自 C++26) |
template< auto f, class T >
function_ref( std::nontype_t<f>, T&& ) -> function_ref</*see below*/>;
|
(3) | (自 C++26) |
1) 此重载仅当
std::is_function_v<F> 为 true 时参与重载决议。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 限定、可选择 noexcept、可选择左值引用限定),其中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)>。
- 推导出的类型为
示例
|
本节内容不完整
原因:缺少示例 |