Skip to content

Instantly share code, notes, and snippets.

@njlr
Last active June 2, 2017 18:22
Show Gist options
  • Save njlr/008759718b186b899c4f0b88af0bdd28 to your computer and use it in GitHub Desktop.
Save njlr/008759718b186b899c4f0b88af0bdd28 to your computer and use it in GitHub Desktop.
// Create a vector of 10 elements, all initialized to 0
auto v = Vector<10>(0);
// Set the 1st element to 7
v[0] = 7;
// Set the 9th element to 3
v[8] = 3;
// Print the sum of all elements
std::cout << v.sum() << std::endl;
// Error!
v[10] = 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment