make use c++11 foreach
upgrade code ‘auto_ptr’ is deprecated to use unique_ptr