Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <functional>
- #include <vector>
- //This document uses tabs of length 4.
- //Compile with the C++11 standard.
- using namespace std;
- const int to_ashes = 0;
- typedef vector<vector<vector<int>>> i3d; //3-Dimensional vector of integers, thus the name.
- function<i3d(int,int,int)> retVec = [](int x, int y, int z) -> i3d {
- i3d vec;
- vec.resize(x);
- for(int a = 0; a < x; ++a){ //this mess actually tells the vectors their size.
- vec[a].resize(y); //accessing a vector will segfault if you don't do this.
- for(int b = 0; b < x; ++b)
- vec[a][b].resize(z);
- }
- return vec;
- };
- class Vec3D {
- //The entire purpose of this class is because I hate writing
- //out vec[val][val][val] instead of simply vec(val,val,val).
- protected:
- i3d vec;
- public:
- Vec3D(int x, int y, int z) {
- vec = retVec(x,y,z);
- };
- /*inline int& at(int x, int y, int z) {
- return vec[x][y][z];
- }*/
- function<int&(int,int,int)> at = [this](int x, int y, int z) -> int& {
- return this->vec[x][y][z];
- };
- };
- int main(int argc, char **argv) {
- Vec3D vec(4,4,4);
- vec.at(0,0,1) = 13;
- cout << vec.at(0,0,1) \
- << endl \
- << vec.at(0,0,0) \
- << endl;
- return to_ashes;
- //the woods decay, the woods decay and fall
- //the vapours weep their burthen to the ground
- //man comes and tills the soil and lies beneath
- //and after many a summer dies the swan.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement