Skip to content

unique_ptr thoughts

Jan Wilmans edited this page Sep 12, 2017 · 3 revisions

class Jan { std::unique_ptr bar; };

class Foo { public: Foo(Bar& bar) : bar(bar) {}

void Purr() { // use bar, but how do we know Jan didn't trash his bar? }

private: Bar& bar; }

int main() { Jan jan; // jan owns a bar }

Clone this wiki locally