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_size - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. array
  3. array
  4. tuple_size

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

履歴 編集

class template
<array>

std::tuple_size(C++11)

namespace std {
  template <class T> class tuple_size; // 先行宣言

  // C++11
  template <class T, std::size_t N>
  struct tuple_size<array<T, N>> {
    static constexpr std::size_t value = N;
  };

  // C++14
  template <class T, std::size_t N>
  struct tuple_size<array<T, N>>
    : integral_constant<std::size_t, N> {};
}

概要

tuple_sizeは、タプルとして見なせる型の要素数を取得するためのクラスである。

要素数は、integral_constantの機能を利用してコンパイル時の定数値として取得できる。

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

例

#include <array>

int main()
{
  static_assert(std::tuple_size<std::array<int, 3>>::value == 3, "");
}

出力

バージョン

言語

  • C++11

処理系

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

参照

  • LWG Issue 2313. tuple_size should always derive from integral_constant<size_t, N>
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.