Because you don't have to store single-element objects in a multi-set. You're thinking of storing something like a string in a multi-set. But that's not what it's made for. You can have any struct you want, and make the comparison be with a single element in the struct.
For example:
struct PhoneBookEntry
{
std::string name;
std::string phoneNumber;
}
In this naive "phone book" entry, there's no reason to have a single entry per name in a phone book. There might be many. So you make a multiset
of PhoneBookEntry
, and you make the comparator be by name
. This way, you can have multiple phone numbers with the same name.
Now you might think that a map is more suitable for this, sure. But this is just an example. If you have a structure where you don't need a key/value but you need the search properties of a set with multiple elements per key, you use a multiset.