Add support for GCC 4.8.

Mostly includes hacks around missing standard library features in
libstdc++ currently; these can be phased out as compiler support improves.