Comparing pointers to unrelated objects has unspecified results.
That would seem to suggest that this program may have undefined behaviour, at the very least because we cannot guarantee a strict weak ordering on the key type:
#include <map>
int main()
{
int x = 0, y = 1;
bool arbitrary = false;
std::map<int*, bool> m{
{&x, arbitrary},
{&y, arbitrary}
};
}
More generally, then, can we say that a map with pointer keys is a dangerous* proposition? Or is there some special rule we can lean on here?
* Academically speaking, that is; in reality I'm not aware of mainstream implementations that will actually raise hell over comparing arbitrary pointers.