Skip to content

Instantly share code, notes, and snippets.

@motonacciu
Created September 17, 2012 19:23
Show Gist options
  • Select an option

  • Save motonacciu/3739242 to your computer and use it in GitHub Desktop.

Select an option

Save motonacciu/3739242 to your computer and use it in GitHub Desktop.
#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