◐ Shell
clean mode source ↗

std::size_t - cppreference.com

Da cppreference.com.

Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.

La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui.

Click here for the English version of this page

<metanoindex/>

<tbody> </tbody>

Elemento definito nell'header

<cstddef>

Elemento definito nell'header

<cstdio>

Elemento definito nell'header

<cstring>

Elemento definito nell'header

<ctime>

typedef /*implementation-defined*/ size_t;

std::size_t è il tipo intero senza segno del risultato dell'operatore

sizeof

e l'operatore

alignof

.

Original:

std::size_t is the unsigned integer type of the result of the

sizeof

operator and the

alignof

operator.

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

Note

size_t può memorizzare la dimensione massima di un oggetto teoricamente possibile di qualsiasi tipo (compresi array). Su molte piattaforme (una eccezione sono sistemi con indirizzamento segmentato) std :: size_t possibile memorizzare il valore di ogni Stato non membro puntatore, in questo caso è sinonimo di std::uintptr_t.

Original:

size_t can store the maximum size of a theoretically possible object of any type (including array). On many platforms (an exception are systems with segmented addressing) std::size_t can safely store the value of any non-member pointer, in which case it is synonymous with std::uintptr_t.

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

std::size_t è comunemente utilizzato per l'indicizzazione matrice e conteggio loop. I programmi che utilizzano altri tipi, come ad esempio, per l'indicizzazione unsigned int matrice potrebbe non funzionare su, ad esempio, Sistemi a 64 bit, quando l'indice supera UINT_MAX o se si basa su 32 bit aritmetica modulare.

Original:

std::size_t is commonly used for array indexing and loop counting. Programs that use other types, such as unsigned int, for array indexing may fail on, e.g. 64-bit systems when the index exceeds UINT_MAX or if it relies on 32-bit modular arithmetic.

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

Quando indicizzazione C + + contenitori, come std::string, std::vector, ecc, il tipo appropriato è il size_type membro typedef forniti da tali contenitori. Di solito è definito come sinonimo di std::size_t.

Original:

When indexing C++ containers, such as std::string, std::vector, etc, the appropriate type is the member typedef size_type provided by such containers. It is usually defined as a synonym for 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.

Esempio

#include <cstddef>
int main()
{
    const std::size_t N = 100;
    int* a = new int[N];
    for(std::size_t n = 0; n<N; ++n)
        a[n] = n;
    delete[] a;
}

Vedi anche

firmato tipo intero restituito quando sottraendo due puntatori

Original:

signed integer type returned when subtracting two pointers

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


(typedef) [modifica]

byte offset dall'inizio di un layout di tipo standard per membro specificato

Original:

byte offset from the beginning of a standard-layout type to specified member

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


(funzione macro) [modifica]