page =
url = https://quuxplusone.github.io/blog
arthur o'dwyer – stuff mostly about c++
Today, while inventing questions for my next C++ Pub Quiz , I ran into a fairly obscure and meaningless divergence among vendors’ implementations of
vector<bool>::reference
. Given:
std::vector<bool> v = {true, true};
The correct way to swap
v[0]
with
is of course
swap(v[0], v[1])
, optionally preceded by
using std::swap
; see “What is the std::swap two-step?” (2020-07-11). But look at all these wrong things you can try! …