Improve compatibility with C++11.

Fixes #5307