◐ Shell
clean mode source ↗

std::size_t – cppreference.com

Aus cppreference.com

<metanoindex/>

<tbody> </tbody>

definiert in Header

<cstddef>

definiert in Header

<cstdio>

definiert in Header

<cstring>

definiert in Header

<ctime>

typedef /*implementation-defined*/ size_t;

std::size_t ist der vorzeichenlose Integer-Typ des Ergebnisses des

sizeof

Operators und des

alignof

Operators.

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.

Notes

size_t kann die maximale Größe jedes theoretisch möglichen Objekts beliebigen Typs (einschließlich Arrays) speichern. Auf vielen Plattformen (eine Ausnahme sind Systeme mit segmentierter Adressierung) kann der Wert eines Non-Member Zeigers sicher in std :: size_t gespeichert werden und ist in diesem ​​Fall gleichbedeutend mit 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 wird häufig für Array-Indizierung und Loop-Zählung verwendet. Programme, die andere Typen für die Indizierung von Arrays verwenden, wie z.B. unsigned int, können fehlschlagen, wenn z.B. auf 64-Bit-Systemen der Index UINT_MAX übersteigt oder wenn die Programme modulare 32-Bit Arithmetik voraussetzen.

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.

Für die Indizierung von C++ Containern, wie std::string, std::vector, etc, wird der geeignete Typ als typedef size_type von der Container-Klasse bereitgestellt und wird in der Regel als Synonym für std::size_t definiert.

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.

Beispiel

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

Siehe auch

vorzeichenbehafteter Ganzzahl-Typ als Ergebnis der Subtraktion zweier Zeiger

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) [edit]

Abstand zwischen dem Beginn eines Standard-Layout-Typs und der benannten Member-Variable in Byte

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.


(funktionieren Makro) [edit]