Use C++11.
Add missing (though somewhat redundant) headers; use std::next.