How would you iterate over the items in a boost::shared_array? Would you do a get() on it and use a raw pointer as the iterator?
Since you're already using boost, maybe like 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();
for (int i : boost::make_iterator_range(ptr, ptr+10))
{
std::cout << i << ',';
}
}
In any case, you need to do your own bookeeping of array's size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With