Question: Let's say I have to accept a size as an argument to an interface which deals with arrays. For e.x.

```
void doSomethingRelatedToArrays(const size_t length)

```

Here, I used `size_t` with the following in mind:

* length must always be positive
* `size_t` is always typedef-ed to the largest unsigned integer type in the system. `std::size_t` can store the maximum size of a theoretically possible object of any type.

However, I should not use unsigned types in my interfaces because the client can pass in a negative number, which is implicitly converted to an unsigned number and I do not have any way of validating it in my method. Refer to Scott Meyer's article on this subject [here](http://www.aristeia.com/Papers/C++ReportColumns/sep95.pdf).

So, I should pass in signed integer type to the API. But how can I get the largest signed integer type in the system? Is there any typedef similar to `size_t` which is signed? Or should I just use `size_t` instead?

Answer: 
The signed equivalent of `size_t` is simply `ssize_t` but this type is not defined in C99 standard even if it is known to many compilers.

For the C99 standard the largest signed integer type is defined as `intmax_t`.

Reference : 7. Library / 7.18 Integer types / 7.18.1.5 Greatest-width integer types
The standard type to use is `std::intmax_t` which is defined in `<cstdint>`. To get the maximum value you can use `std::numeric_limits<intmax_t>::max()`.

Sample code:

```
#include <cstdint>
#include <iostream>
#include <limits>

int main(int argc, char* argv[]) {
    std::cout << "max size = " << std::numeric_limits<intmax_t>::max() << std::endl;
}

```