Skip to content

Instantly share code, notes, and snippets.

@motonacciu
Created September 17, 2012 20:53
Show Gist options
  • Select an option

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

Select an option

Save motonacciu/3739697 to your computer and use it in GitHub Desktop.
#include <memory>
class Instance {
std::weak_ptr<const Instance> ref;
int value;
public:
Instance (const std::shared_ptr<const Instance>& other, int value) :
ref(other), value(value) { }
void setRef(const std::shared_ptr<const Instance>& ref) {
this->ref = ref;
}
std::shared_ptr<const Instance> getRef() const {
return ref.lock();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment