close
The Wayback Machine - https://web.archive.org/web/20180601130112/http://ja.cppreference.com:80/w/cpp/language/sizeof...
名前空間
変種
操作

sizeof... operator

提供: cppreference.com
< cpp‎ | language

 
 
C++言語
一般的なトピック
フロー制御
条件付き実行文
繰り返し文 (ループ)
ジャンプ文
関数
関数宣言
ラムダ関数宣言
inline 指定子
例外指定 (非推奨)
noexcept 指定子 (C++11)
例外
名前空間
指定子
decltype (C++11)
auto (C++11)
alignas (C++11)
記憶域期間指定子
初期化
代替表現
リテラル
ブーリアン - 整数 - 浮動小数点
文字 - 文字列 - nullptr (C++11)
ユーザ定義 (C++11)
ユーティリティ
属性 (C++11)
typedef 宣言
型エイリアス宣言 (C++11)
キャスト
暗黙の変換 - 明示的な変換
static_cast - dynamic_cast
const_cast - reinterpret_cast
メモリ確保
クラス
クラス固有の関数特性
特別なメンバ関数
テンプレート
その他
 
クエリパラメーターパック内の要素の数.
Original:
Queries the number of elements in a パラメーターパック.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] 構文

sizeof...( parameter_pack ) (C++11およびそれ以降)
タイプstd::size_tのオブジェクトを返します.
Original:
Returns an object of type std::size_t.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 説明

パラメーターパック内の要素数を返します。.
Original:
Returns the number of elements in a パラメーターパック.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] キーワード

sizeof

[編集]

#include <iostream>
 
template<class... Args>
std::size_t f()
{
    return sizeof...(Args);
}
 
int main()
{
    std::cout << f<>() << '\n'
              << f<int>() << '\n'
              << f<char, int, double>() << '\n';
}

出力:

0
1
3

[編集] 参照