On Fri, Oct 16, 2020 at 3:38 PM Bartosz Golaszewski <brgl@xxxxxxxx> wrote: > > On Fri, Oct 16, 2020 at 12:29 PM Helmut Grohne <helmut.grohne@xxxxxxxxxx> wrote: > > > > [snip] > > > > +chip::chip(const ::std::weak_ptr<::gpiod_chip>& chip_ptr) > > > + : _m_chip(chip_ptr) > > > +{ > > > + > > > +} > > > + > > > > I think what happens here is that you upgrade a weak_ptr to a > > shared_ptr. Wouldn't it be more natural to request a > > > > ::std::shared_ptr<::gpiod_chip> && > > > > here and thus make the ownership-taking more explicit? It would be done > > on the caller-side and thus be more transparent. Stuffing weak_ptrs > > should continue to work. > > > > Sure, sounds good. > After a second look - I'm not sure if this is actually better. By taking weak_ptr reference as argument we benefit from implicit conversion to shared_ptr via shared_ptr's constructor taking weak_ptr as argument. What you propose would require us to always instantiate a shared_ptr in the argument list when calling the chip's constructor and makes code uglier in the end IMO. Bartosz