Namespaces
Variants

deduction guides for std::function_ref

From cppreference.net
Utilities library
Function objects
Function invocation
(C++17) (C++23)
Identity function object
(C++20)
Old binders and adaptors
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
( until C++17* ) ( until C++17* )
( until C++17* ) ( until C++17* )

( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
定义于头文件 <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 起)
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 ) >

示例