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. array
  3. array
  4. tuple_element

最終更新日時: 2026年09月19日 21時31分51秒 (JST)
rotarymars が更新

履歴 編集

class template
<array>

std::tuple_element(C++11)

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

  template <std::size_t I, class T, std::size_t N>
  struct tuple_element<I, array<T, N>> {
    static_assert(I < N, implementation-defined);
    using type = T;
  };
}

概要

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

<array>ヘッダでは、arrayクラスに関する特殊化を定義する。 arrayの特殊化では、tuple_element::typeは常にTである。

適格要件

  • I < Nであること

例

#include <array>
#include <type_traits>

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

  static_assert(std::is_same<
                  std::tuple_element<1, std::array<int, 2>>::type,
                  int
                >::value, "");
}

出力

バージョン

言語

  • C++11

処理系

  • Clang: 9.0.1 ✅
  • GCC: 4.7.0 ✅
  • Visual C++: 2008 (std::tr1) ✅, 2010 ✅, 2012 ✅

備考

GCC 4.7、およびVisual C++ 10.0のarrayに対するtuple_elementの特殊化では、Iの境界チェックがない。

You are visitor 01402503 — 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.