// Less evil code:
int xs_a = min( xs[a], xs[b] ); // (Yep. This was over integers.)
int xs_b = max( xs[a], xs[b] );
replace( xs.begin(), xs.end(), xs_b, xs_a );
Took me half an hour to figure out why my Kruskal MST wasn't working.
:@
const should be renamed readonlyfromthisparticularvariable but programmers are too lazy to type that out.
Also, there's nothing wrong with the behavior of those functions - what if you really did want references to be used and didn't want to deal with the overhead/hassle of a std::reference_wrapper? Copies of primitives are cheap, whereas wrapper classes are not.