How can I configure travis-ci such that my project builds with more than one version of a compiler?

Say, I want to build it with gcc-4.8, gcc-4.9, clang-3.4, clang-3.5 and clang-3.6.

I know how to build on both gcc and clang, but not on more than one version of them.

To give a little bit more context, my project is a C++ library and I want to ensure compatibility with those compilers.