When to use "rsize_t" instead of "size_t"?

Asked

Viewed 55 times

2

What’s the difference between rsize_t and size_t, looking in the draft I found in the item K.3.6 General Utilities :

rsize_t
which is the type size_t;

which means they’re the same type, but I couldn’t find a description of the difference, which apparently is in the use.

1 answer

3


Basically it’s a semantic question, you get a better idea of what you’re doing. So it says you’re choosing a size within a certain range. In fact it seems that they consider it useless and there is a proposal that is removed from the specification since the compilers decided not to adopt it, so don’t waste time with it.

There is even usefulness when different semantics make more sense, and in a certain way the size_t may be replaced by a int (not in all situations), and in fact in exercises and naive codes we see it all the time, but it’s not correct, it just works (in most cases). This type is created to handle a memory size and not just any number.

If programmers looked more at semantics of things the applications would be much better in every sense, including being better of maintenance.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.