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

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -