Skip to content

Commit

Permalink
README: C++17 Structure Bindings
Browse files Browse the repository at this point in the history
Modernize "first read" C++ example with structured bindings
  • Loading branch information
ax3l committed Jan 15, 2022
1 parent 5639a9d commit b1de4fd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ Writing & reading through those backends and their associated files is supported

auto s = openPMD::Series("samples/git-sample/data%T.h5", openPMD::Access::READ_ONLY);

for( auto const& i : s.iterations ) {
std::cout << "Iteration: " << i.first << "\n";
for( auto const [step, it] : s.iterations ) {
std::cout << "Iteration: " << step << "\n";

for( auto const& m : i.second.meshes ) {
std::cout << " Mesh '" << m.first << "' attributes:\n";
for( auto const& val : m.second.attributes() )
for( auto const [name, mesh] : it.meshes ) {
std::cout << " Mesh '" << name << "' attributes:\n";
for( auto const& val : mesh.attributes() )
std::cout << " " << val << '\n';
}

for( auto const& p : i.second.particles ) {
std::cout << " Particle species '" << p.first << "' attributes:\n";
for( auto const& val : p.second.attributes() )
for( auto const [name, species] : it.particles ) {
std::cout << " Particle species '" << name << "' attributes:\n";
for( auto const& val : species.attributes() )
std::cout << " " << val << '\n';
}
}
Expand Down

0 comments on commit b1de4fd

Please sign in to comment.