Use C++11 headers rather than TR1.

Todo: many instances of shared_ptr can be replaced by unique_ptr.
Replace many shared_ptrs by unique_ptrs.
Infer iterator types.
Remove TR1 test.