You could use std::list::front and std::list::back here.