std:: tuple_element <std::complex>
From cppreference.net
C++
Numerics library
| Common mathematical functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Mathematical special functions (C++17) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Mathematical constants (C++20) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Basic linear algebra algorithms (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Data-parallel types (SIMD) (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Floating-point environment (C++11) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Complex numbers | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Numeric array (
valarray
)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Pseudo-random number generation | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bit manipulation (C++20) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Saturation arithmetic (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Factor operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Interpolations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Generic numeric operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| C-style checked integer arithmetic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::complex
| Member functions | ||||
| Non-member functions | ||||
| Exponential functions | ||||
| Power functions | ||||
| Trigonometric functions | ||||
| Hyperbolic functions | ||||
| Helper types | ||||
|
(C++26)
|
||||
|
tuple_element
<std::complex>
(C++26)
|
||||
|
定义于头文件
<complex>
|
||
|
template
<
std::
size_t
I,
class
T
>
struct tuple_element < I, std:: complex < T >> ; |
(C++26 起) | |
针对
std::complex
的
std::tuple_element
部分特化,通过类似元组的语法提供对
complex
底层实数和虚数类型的编译时访问。这些特化为结构化绑定支持而提供。若
I
>=
2
,则程序非良构。
目录 |
成员类型
| 成员类型 | 定义 |
type
|
T
|
注释
| 功能测试 宏 | 值 | 标准 | 功能 |
|---|---|---|---|
__cpp_lib_tuple_like
|
202311L
|
(C++26) | 为 std::complex 添加元组协议 |
示例
运行此代码
#include <complex> #include <type_traits> static_assert([z = std::complex<float>()] { using T = decltype(z); return #if __cpp_lib_tuple_like >= 202311L std::is_same_v<std::tuple_element_t<0, T>, float> && std::is_same_v<std::tuple_element_t<1, T>, float> && #endif std::is_same_v<T::value_type, float>; }()); int main() {}
参见
| 结构化绑定 (C++17) | 将指定名称绑定到初始化器的子对象或元组元素 |
|
(C++11)
|
获取类元组类型的元素类型
(类模板) |
|
(C++26)
|
获取
std::complex
的大小
(类模板特化) |
|
(C++26)
|
从
std::complex
获取对实部或虚部的引用
(函数模板) |