Fixed build errors from GCC 4.6.

Apparently, GCC 4.6 can't compile std::shared_ptr<const T>.