fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iterator>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. void SetDataReferences(int*const* pVector, const size_t length) {
  9. transform(pVector, next(pVector, length), ostream_iterator<int>(cout, "\n"), [](const auto i) { return *i; });
  10. }
  11.  
  12. void SetDataReferences(int** pVector, const size_t length) {
  13. for(const auto finish = next(pVector, length); pVector != finish; ++pVector) {
  14. delete *pVector;
  15. *pVector = new int{ 0 };
  16. }
  17. }
  18.  
  19. int main() {
  20. vector<void*> foo = { new int{ 13 }, new int{ 42 } };
  21.  
  22. SetDataReferences(reinterpret_cast<int**>(foo.data()), foo.size());
  23. SetDataReferences(reinterpret_cast<int*const*>(foo.data()), foo.size());
  24. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
0
0