GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::tuple_element - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. complex
  3. complex
  4. tuple_element

最終更新日時: 2024年08月02日 15時00分52秒 (JST)
Akira Takahashi が更新

履歴 編集

class template
<complex>

std::tuple_element(C++26)

namespace std {
  template <std::size_t I, class T> class tuple_element; // 先行宣言

  template<size_t I, class T>
  struct tuple_element<I, complex<T>> {
    using type = T;
   };
}

概要

tuple_elementは、タプルとして見なせる型から、I番目の要素型を取得するためのクラスである。

<complex>ヘッダでは、std::complexクラスに関する特殊化を定義する。

適格要件

  • I < 2であること

例

#include <complex>
#include <type_traits>

int main()
{
  static_assert(std::is_same<
                  std::tuple_element<0, std::complex<float>>::type,
                  float
                >::value, "");

  static_assert(std::is_same<
                  std::tuple_element<1, std::complex<float>>::type,
                  float
                >::value, "");
}

出力

バージョン

言語

  • C++26

処理系

  • Clang: 19.0 ❌
  • GCC: 14 ❌
  • Visual C++: 2022 Update 10 ❌

参照

  • P2819R2 Add tuple protocol to complex
    • C++26からstd::complexにタプルインタフェースがサポートされた
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.