Created
September 17, 2012 19:23
-
-
Save motonacciu/3739242 to your computer and use it in GitHub Desktop.
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 <vector> | |
| class Instance { | |
| const Instance* ref; | |
| int value; | |
| public: | |
| Instance (const Instance* other, int value) : | |
| ref(ref), value(value) { } | |
| }; | |
| class InstanceMgr { | |
| std::vector<Instance> repos; | |
| public: | |
| InstanceMgr& add(int v) { | |
| repos.emplace_back(repos.empty() ? nullptr : &repos.back(), v); | |
| return *this; | |
| } | |
| }; | |
| int main(int argc, char* argv[]) { | |
| InstanceMgr mgr; | |
| mgr.add(2) | |
| .add(3) | |
| .add(4); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment