c++11 - boost::shared_ptr<std::vector<something>> usage of operator[] -
i have struct looks this. typedef struct supercellboxstruct { float_tt cmx,cmy,cmz; /* fractional center of mass coordinates */ float_tt ax,by,cz; boost::shared_ptr<std::vector<atom>> atoms; /* contains atoms within super cell */ } supercellbox; now when want access atoms[i] error: invalid use of ‘boost::detail::sp_array_access >::type {aka void}’ what proper way of passing around shared vector in application, or correct way access operator[]? prefer unique_ptr<t[]> if can, because operator[] free (§ 20.7.1.3.3): quick demo: live on coliru #include <memory> #include <iostream> int main() { std::unique_ptr<int[]> p(new int[3] { 1,2,3 }); std::cout << "before: " << p[0] << ", " << p[1] << ", " << p[2] << ";\n"; p[1] = 42; std::cout << "after: " << p[0] << ", " <...