◐ Shell
clean mode source ↗

sizeof... operator — cppreference.com

De cppreference.com

<metanoindex/>

Interroge le nombre d'éléments dans un Paquet de paramètre .

Original:

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Syntaxe

sizeof...( parameter_pack ) (depuis C++11)

Retourne un objet de type .. 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.

Explication

Retourne le nombre d'éléments dans un Paquet de paramètre .

Original:

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Mots-clés

sizeof

Exemple

#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';
}

Résultat :

Voir aussi