Make entire library code compile on MSVC & gcc.

Also, can you reorder the arguments to `Container,dim,spacedim`? The order you choose is used in many places of the library, but that's mostly because of a historical accident (we didn't use to have `spacedim`, so it had to be added to the end).