Boost logo

Boost :

Subject: Re: [boost] Is there any interest in non-owning pointer-like types?
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2017-02-01 17:18:39

On 01/02/2017 07:47, Joseph Thomson wrote:
> For some time, I have been developing a pair of non-owning pointer-like
> types that I am currently calling `observer_ptr` and `observer`. I had
> planned to propose their addition to the C++ standard library, but I have
> been informed by the author of the original `observer_ptr` proposal
> <> that
> the ISO C++ committee has rejected his proposal and made clear that it
> feels there is no place in the standard library for such types, believing
> that this role is filled to a satisfactory degree by regular pointers. I
> wholeheartedly disagree with this assessment, so I am bringing my proposal
> here instead.

I don't think that exactly accurate. Rather it is that the GSL's
proposed schema of:

* owner<T> is an owning pointer
* span<T> is a borrowed pointer/reference/view
* C type pointers are non-owning, non-borrowed

... has general wide agreement in principle, if not in exact
formulation. The Library Fundamentals TS v2 does have an observer_ptr in
std::experimental, but there is general lack of sureness as to what it
actually contributes when a non-annotated pointer according to the GSL
schema is either an observer by definition, or unupgraded code.

I'd need a fair bit of convincing that observer<T> has merit in any form
except additional clarity to help demarcate unupgraded code from
upgraded code. If that's your argument, and you're not doing funny
things with implicit conversion from T& and other funny non-GSL
semantics, I'd suppose this though I'd suggest you actually contribute
it to GSL itself and persuade Neil to let it in.

The GSL is a *much* better home for it than Boost because then you'll
have Bjarne batting for it, plus static checking support from Microsoft
in VS2017 and Google via clang-tidy. You'll also get a *huge* userbase
almost instantly, because the GSL or rather one of its C++ 98 clones is
seeing exponential growth recently. It's amazingly useful for upgrading
ancient C++ codebases.


ned Productions Limited Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at