Maps only guard against duplicate keys. Duplicate values are perfectly fine (and desirable).
Maybe you want to use std::set instead?
i need to insert many objects, map will keep unique keys. if it was previously inserted, it will increase the int(second) ++M[temp];
but in my previous code temp key is inserted 3 times :(
i need object counter alike the word counter in the following example.
> but in my previous code temp key is inserted 3 times :(
as Disch pointed out, that's because your comparison function is ill-formed. temp<temp is true, so the map "wrongfully" thinks that it is another element.
Most Standard Library containers (including std::vector in your example) can be compared with operator<. If for some reason you are working with a type that cannot be compared this way, then after using std::tie you can do traditional comparison. You could also implement operator< for the type so that you can stick to just using std::tie.