I would have expected such a useful data structure to be included in the C++ Standard Library
but I can't seem to find it.
It is not, but there is one in boost: http://www.boost.org/doc/libs/1_64_0/libs/disjoint_sets/disjoint_sets.html, so if you want an off-the-shelf implementation I'd recommend this.