How do you get the number of elements in a std::map as an unsigned long?

Assuming you have an object like this:

```
std::map<unsigned long, someClass *> myNightmare;
```

I have been trying to figure out how to get its number of elements. You see, I need this number as an unsigned long, and it doesn't seem correct to just do this:

```
unsigned long count = myNightmare.size();
```

So how should you get the number of elements as an unsigned long?

Use static cast.

```
long unsigned mySize = static_cast<long unsigned>(myNightmare.size());
```