Skip to content

Instantly share code, notes, and snippets.

@TyounanMOTI
Created October 19, 2011 09:51
Show Gist options
  • Save TyounanMOTI/1297865 to your computer and use it in GitHub Desktop.
Save TyounanMOTI/1297865 to your computer and use it in GitHub Desktop.
boost::multi_array vs Range based for loop
#include <gtest/gtest.h>
#include <boost/multi_array.hpp>
TEST(MultiArrayTest, Fill) {
boost::multi_array<int, 2> subject(boost::extents[20][10]);
for (auto x : subject) {
for (auto &y : x) {
y = 10;
}
}
EXPECT_EQ(10, subject[5][4]);
}
@TyounanMOTI
Copy link
Author

preffered:

for (auto &x : subject) {
  x = 10;
}

not to think about dimension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment