I need a container to store a value (int) according to two attributes, source (int) and destination (int) i.e. when a source sends something to a destination, I need to store it
If you want to keep using a vector but want to add a check for whether the item contains a valid value, look at boost::optional. The type would now be std::vector
.
You can also use a map, but the key into the map needs to be both IDs not just one.
std::map,int>
Edit: std::pair
implements a comparison operator operator<
that should be sufficient for use in a map, see http://en.cppreference.com/w/cpp/utility/pair/operator_cmp.