std::tuple_elementstd::complex - cppreference.com (original) (raw)
| 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 | |
| gcd(C++17) | lcm(C++17) |
| Interpolations | |
| midpoint(C++20) | lerp(C++20) |
| Generic numeric operations | |
| iota(C++11) ranges::iota(C++23) accumulate inner_product adjacent_difference partial_sum | reduce(C++17) transform_reduce(C++17) inclusive_scan(C++17) exclusive_scan(C++17) transform_inclusive_scan(C++17) transform_exclusive_scan(C++17) |
| C-style checked integer arithmetic | |
| ckd_add(C++26) ckd_sub(C++26) | ckd_mul(C++26) |
| Member functions | |
|---|---|
| complex::complex complex::operator= complex::real complex::imag | complex::operator+=complex::operator-=complex::operator*=complex::operator/= |
| Non-member functions | |
| operator+operator- operator+operator-operator*operator/ operator==operator!=(until C++20) operator<> get(std::complex)(C++26) | real imag abs arg norm conj proj(C++11) polar [operator""ioperator""ifoperator""il](operator%2522%2522i.html "cpp/numeric/complex/operator""i")(C++14)(C++14)(C++14) |
| Exponential functions | |
| loglog10exp | |
| Power functions | |
| powsqrt | |
| Trigonometric functions | |
| sin cos tan asin(C++11) acos(C++11) atan(C++11) | |
| Hyperbolic functions | |
| sinh cosh tanh asinh(C++11) acosh(C++11) atanh(C++11) | |
| Helper types | |
| tuple_sizestd::complex(C++26) | |
| tuple_elementstd::complex(C++26) |
| Defined in header | | | | -------------------------------------------------------------------------------------------------------------------------------- | | ------------- | | template< std::size_t I, class T > struct tuple_element<I, std::complex<T>>; | | (since C++26) |
The partial specializations of std::tuple_element for std::complex provide compile-time access to the underlying real and imaginary number type of a complex, using tuple-like syntax. They are provided for structured binding support. The program is ill-formed if I >= 2.
Contents
[edit] Member types
| Member type | Definition |
|---|---|
| type | T |
[edit] Notes
| Feature-test macro | Value | Std | Feature |
|---|---|---|---|
| __cpp_lib_tuple_like | 202311L | (C++26) | Add tuple protocol to std::complex |
[edit] Example
Run this code
#include #include static_assert([z = std::complex()] { 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() {}
[edit] See also
| Structured binding (C++17) | binds the specified names to sub-objects or tuple elements of the initializer[edit] |
|---|---|
| tuple_element(C++11) | obtains the element types of a tuple-like type (class template) [edit] |
| std::tuple_sizestd::complex(C++26) | obtains the size of a std::complex (class template specialization) [edit] |
| get(std::complex)(C++26) | obtains a reference to real or imaginary part from a std::complex (function template) [edit] |