Created
November 15, 2016 21:24
-
-
Save matt-42/422fb0b222d0768d9e2eb45fb8880288 to your computer and use it in GitHub Desktop.
iod::array_view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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