Skip to content

Commit

Permalink
Expose iteraors for access to the data in checkpoint
Browse files Browse the repository at this point in the history
 - Update example to use std::copy and  iterators to write to a file
  • Loading branch information
aserio committed Sep 20, 2017
1 parent ccf8f8d commit 7189f7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions hpx/util/checkpoint.hpp
Expand Up @@ -79,6 +79,17 @@ namespace util
return false;
}
}

// Expose iterators to access data held by checkpoint
using const_iterator = std::vector<char>::const_iterator;
const_iterator begin() const
{
return data.begin();
}
const_iterator end() const
{
return data.end();
}

void load(std::string file_name)
{
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/util/checkpoint.cpp
Expand Up @@ -128,7 +128,10 @@ int main()
std::vector<float> vec7{1.02, 1.03, 1.04, 1.05};
hpx::future<checkpoint> fut_7=save_checkpoint(vec7);
checkpoint archive7 = fut_7.get();
test_file_7.write(archive7.data.data(),archive7.size());
std::copy(
archive7.begin() // Write data to ofstream
, archive7.end() // ie. the file
, std::ostream_iterator<char>(test_file_7));
test_file_7.close();

std::vector<float> vec7_1;
Expand Down

0 comments on commit 7189f7d

Please sign in to comment.