std:: basic_common_reference <std::reference_wrapper>
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Old binders and adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Non-member functions | ||||
|
(C++26)
(C++26)
|
||||
| Deduction guides (C++17) | ||||
| Helper classes | ||||
|
basic_common_reference
<std::reference_wrapper>
(C++23)
|
|
定义于头文件
<functional>
|
||
|
template
<
class
R,
class
T,
template
<
class
>
RQual,
template
<
class
>
TQual
>
|
(1) | (C++23 起) |
|
template
<
class
T,
class
R,
template
<
class
>
TQual,
template
<
class
>
RQual
>
|
(2) | (C++23 起) |
|
辅助概念
|
||
|
template
<
class
R,
class
T,
class
RQ,
class
TQ
>
concept
/*ref-wrap-common-reference-exists-with*/
=
|
(3) | ( 仅用于阐释* ) |
reference_wrapper
的公共引用类型(表示为
R
)与类型
T
(分别应用了 cv 和引用限定符,对应表示为
RQ
和
TQ
)的公共引用类型,等价于应用了左值引用的
R
底层类型与
TQ
的公共引用类型。
公共引用类型仅当
R
是唯一
reference_wrapper
、应用左值引用的
R
底层类型与
TQ
存在公共引用类型且
RQ
必须可转换到该类型时才会被定义。
仅用于阐述的常量 /*is-ref-wrapper*/ < R > 当且仅当 R 是 std::reference_wrapper 的特化时为 true 。
目录 |
成员类型
| 成员类型 | 定义 |
type
|
std:: common_reference_t < typename R :: type & , TQual < T >> ( 1,2 ) |
注解
| 功能测试 宏 | 值 | 标准 | 功能特性 |
|---|---|---|---|
__cpp_lib_common_reference_wrapper
|
202302L
|
(C++23) | 使 std::common_reference_t 对 std::reference_wrapper 成为引用类型 |
示例
#include <concepts> #include <functional> static_assert(std::same_as<std::common_reference_t<int&, std::reference_wrapper<int>>, int&>); static_assert(std::same_as<std::common_reference_t<std::reference_wrapper<int>&, int&>, int&>); static_assert(std::same_as<std::common_reference_t<int&, const std::reference_wrapper<int>&>, int&>); int main() {}
参见
|
确定一组类型的公共引用类型
(类模板) |