[libcxx-commits] [libcxx] [libc++] Implement P2819: Add tuple protocol to complex (PR #72776)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Nov 20 04:42:53 PST 2023


================
@@ -1538,6 +1549,73 @@ inline namespace literals
 } // namespace literals
 #endif
 
+#if _LIBCPP_STD_VER >= 26
+// Tuple interface [complex.tuple]
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_size<complex<_Tp>>
+  : public integral_constant<size_t, 2> {};
+
+template<size_t _Ip, class _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, complex<_Tp>>
+{
+  static_assert(_Ip < 2, "Index out of bounds in std::tuple_element<std::complex<T>>");
+
+  using type _LIBCPP_NODEBUG = _Tp;
+};
+
+template <size_t _Ip>
+struct __get_complex
+{
+  static_assert(_Ip < 2, "Index out of bounds in std::get<std::complex<T>>");
+
+  template <typename _Tp>
+  struct to_array_type;
+
+  template <typename _Tp>
+  struct to_array_type<complex<_Tp>>
----------------
PragmaTwice wrote:

Removed.

https://github.com/llvm/llvm-project/pull/72776


More information about the libcxx-commits mailing list