C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] non_owned_ptr
From: Jorg Brown (jorg.brown_at_[hidden])
Date: 2019-11-10 23:20:35


> Is it in serious consideration?

Consideration for what? It's part of Version 2 of the C++ Extensions for
Library Fundamentals
<https://en.cppreference.com/w/cpp/experimental/lib_extensions_2>, ISO/IEC
TS 19568:2017.

Code such as this currently compiles:

#include <experimental/memory>

int f() {
  int a = 1;
  std::experimental::observer_ptr<int> op(&a);
  *op += 1;
  return a;
}

As can be seen at https://godbolt.org/z/GQFeh4

= - = - = - = - =

> the current convention of using raw pointers to represent transient
pointers.

std::span<T, 1> might also fill that need, depending on your application.

On Sun, Nov 10, 2019 at 9:09 PM Steve Weinrich via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> None. I was not aware of observer_ptr. Is it in serious consideration?
>
> On Sun, Nov 10, 2019, 22:03 Andrew Tomazos <andrewtomazos_at_[hidden]>
> wrote:
>
>> How does it differ from:
>>
>> https://en.cppreference.com/w/cpp/experimental/observer_ptr
>>
>> On Mon, Nov 11, 2019 at 1:45 PM Steve Weinrich via Std-Proposals <
>> std-proposals_at_[hidden]> wrote:
>>
>>> I was thinking that a non_owned_ptr would be a good std addition. The
>>> idea is to formalize the current convention of using raw pointers to
>>> represent transient pointers (transient_ptr might be a better name).
>>>
>>> Aside from a lot of details, it would simply be a template wrapper
>>> around a raw pointer. On destruction, the wrapper would do nothing.
>>>
>>> This would allow the enforcement of the intended behavior.
>>>
>>> What do you all think?
>>> --
>>> Std-Proposals mailing list
>>> Std-Proposals_at_[hidden]
>>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>>
>> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>



STD-PROPOSALS list run by herb.sutter at gmail.com

Standard Proposals Archives on Google Groups