When to use std::size_t?
Posted
by nhaa123
on Stack Overflow
See other posts from Stack Overflow
or by nhaa123
Published on 2009-12-23T09:02:01Z
Indexed on
2010/06/15
8:02 UTC
Read the original article
Hit count: 303
Hi,
I'm just wondering should I use std::size_t
for loops and stuff instead of int
?
For instance:
#include <cstdint>
int main()
{
for (std::size_t i = 0; i < 10; ++i)
// std::size_t OK here? Or should I use, say, unsigned int instead?
}
In general, what is the the best practice regarding when to use std::size_t
?
© Stack Overflow or respective owner