boostorg / smart_ptr

Boost.org smart_ptr module
http://boost.org/libs/smart_ptr
109 stars 110 forks source link

observer_ptr<T> #70

Open bernhardmgruber opened 5 years ago

bernhardmgruber commented 5 years ago

There was much disagreement on the future of std::observer_ptr<T> during the WG21 Cologne meeting this summer (objection against moving it into the standard, but no consensus for dropping it from the library fundamentals TS3). So maybe Boost is the right place for this handy little utility.

What are your thoughts? Would you accept a PR adding observer_ptr<T> to Boost.SmartPtr?

pdimov commented 5 years ago

Possibly, but I'm not convinced that observer_ptr is the right name. :-)

glenfe commented 5 years ago

@bernhardmgruber You can propose observer_ptr as a new Boost library too. fixed_string is going this route instead of going into Boost.Container. The same for span.

bernhardmgruber commented 5 years ago

@pdimov The name has been bikesheded to death by WG21 during the years and observer_ptr<T> was the best they got. I don't want to reopen the discussion, because I feel less qualified to pick a better name ;) @glenfe Would you prefer having observer_ptr<T> in its own library? I thought that going the way through an existing library might be easier than sending an entire new one through the review process.

glenfe commented 5 years ago

Users have that preference now-a-days, to be able to pull in small independent components without dependencies on other Boost libraries.

The other advantage is that the facility will receive a Boost review. It had a WG21 review, but (speaking as a WG21 and C++ Standard committee member) a Boost review is worth it.

pdimov commented 5 years ago

I don't see much to review there. Except the name. That part of the review will be fun. :-)

pdimov commented 5 years ago
POLLS 

Drop observer_ptr from the TS. 

SF  F  N  A  SA  
7  9  7  7  4  

Move observer_ptr to Annex D of the standard (deprecated). 

SF  F  N  A  SA  
5  6  5  13  6  

Move observer_ptr toward the WD, no special policy. 

SF  F  N  A  SA  
2  4  4  14  12  

Move observer_ptr toward the WD, with LEWG policy to ignore it in the standard. 

SF  F  N  A  SA  
4  8  9  5  9  

Not very encouraging.

glenfe commented 5 years ago

Should be an easy review then. :)

pdimov commented 5 years ago

Actually no, I take that back. There are some parts of the design that I'd change. The pointer constructor should be implicit; there shouldn't be a conversion to a raw pointer; and, arguably, shared_ptr should be implicitly convertible to observer_ptr.

bernhardmgruber commented 5 years ago

My colleague @MFHava and me finally found some time to put together a simple implementation with some documentation. Most of it is taken quite directly from the working draft. I talked to Walter E. Brown during the last WG21 meeting in Cologne and he was fine with letting us try to publish his work as a boost library.

The repository is here: https://github.com/MFHava/observer_ptr

How would you recommend to proceed now? I guess there will be a lot to polish before we can start an actual boost review, whatever that means.

glenfe commented 5 years ago

Some links: