c++ - Iterate over boost::shared_array -
how iterate on items in boost::shared_array
? get()
on , use raw pointer iterator?
since you're using boost, maybe this:
#include <boost/shared_array.hpp> #include <boost/range.hpp> #include <iostream> int main() { boost::shared_array<int> arr(new int[10]()); int* ptr = arr.get(); (int : boost::make_iterator_range(ptr, ptr+10)) { std::cout << << ','; } }
in case, need own bookeeping of array's size.
Comments
Post a Comment