Is this idiomatic C++?