Skip to content

Instantly share code, notes, and snippets.

@matt-42
Created November 15, 2016 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matt-42/422fb0b222d0768d9e2eb45fb8880288 to your computer and use it in GitHub Desktop.
Save matt-42/422fb0b222d0768d9e2eb45fb8880288 to your computer and use it in GitHub Desktop.
iod::array_view
#include <iostream>
#include <iod/array_view.hh>
#include "symbols.hh"
#include <cassert>
int main()
{
using namespace iod;
using namespace s;
{
std::vector<int> A = {1,2,3,4};
auto v = array_view(A.size(), [&] (int i) {
return A[i] * 2; });
for (int i = 0; i < int(v.size()); i++)
assert(v[i] == (i+1) * 2);
for (auto x : v) std::cout << x << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment