std::size_t
Материал из cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Заголовочный файл <cstddef>
|
||
| Заголовочный файл <cstdio>
|
||
| Заголовочный файл <cstring>
|
||
| Заголовочный файл <ctime>
|
||
| typedef /*implementation-defined*/ size_t; |
||
std::size_t является целым числом без знака тип результата оператора sizeof и 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.
You can help to correct and verify the translation. Click here for instructions.
[править] Notes
size_t можно записать максимальный размер теоретически возможного объекта любого типа (в том числе массив). На многих платформах (исключением являются системами с сегментированной адресации) STD :: size_t можно безопасно хранить значение любого не являющегося членом указателя, в этом случае он является синонимом 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.
You can help to correct and verify the translation. Click here for instructions.
std::size_t обычно используется для индексации массива и цикла счета. Программы, которые используют другие виды, такие как unsigned int, для индексации массивов может не на, например, 64-битные системы, когда индекс превышает UINT_MAX или если она опирается на 32-разрядной арифметике.
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.
You can help to correct and verify the translation. Click here for instructions.
При индексировании C + + контейнеры, такие как std::string, std::vector, и т.д., соответствующие типу является членом ЬурейеЕ size_type, предоставляемые такими контейнерами. Она обычно определяется как синоним 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.
You can help to correct and verify the translation. Click here for instructions.
[править] Пример
#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; }
[править] См. также
| целое число типа возвращается при вычитании двух указателей 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. (определение типа) | |
| байтовое смещение от начала стандартной верстки типа указанного члена 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. (функция-макрос) | |