Skip to content

unique_ptr thoughts

Jan Wilmans edited this page Sep 12, 2017 · 3 revisions
class Jan
{
  std::unique_ptr<Bar> bar;
};

class Foo
{
public:
  Foo(Bar& bar) 
    : bar(bar) {}
  
  void Purr()
  {
    // use bar, but can we have a way to check that Jan didn't trash his bar?
  }

private:
  Bar& bar;
}

int main()
{
  Jan jan; // jan owns a bar
}
Clone this wiki locally