Topic: N3830 - Scoped Resource - Generic RAII Wrapper for


Author: Adi Shavit <adishavit@gmail.com>
Date: Sat, 25 Jan 2014 23:16:13 -0800 (PST)
Raw View
------=_Part_762_31022966.1390720573144
Content-Type: text/plain; charset=UTF-8

Hi,

  I've been longing for this for a long time. I look forward to seeing
something like this in the standard.

How would scoped_resource handle release functions that take the address-of
the resource?
I've seen many APIs that take a ** so they can set the ptr to NULL.
For example see this:
http://docs.opencv.org/modules/core/doc/old_basic_structures.html?highlight=cvreleaseimage#releaseimage

I guess you could do it with a lambda but then you actually need a way to
reference the resource itself to take its address.
Also, writing this lambda every time is tedious and error prone as this is
quite a common API approach.

Adi

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_762_31022966.1390720573144
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi,</div><div><br></div><div>&nbsp; I've been longing=
 for this for a long time. I look forward to seeing something like this in =
the standard.</div><div><br></div><div>How would <font face=3D"courier new,=
 monospace">scoped_resource</font> handle release functions that take the a=
ddress-of the resource?</div><div>I've seen many APIs that take a <font fac=
e=3D"courier new, monospace">**</font> so they can set the ptr to <font fac=
e=3D"courier new, monospace">NULL</font>.&nbsp;</div><div>For example see t=
his: <a href=3D"http://docs.opencv.org/modules/core/doc/old_basic_structure=
s.html?highlight=3Dcvreleaseimage#releaseimage">http://docs.opencv.org/modu=
les/core/doc/old_basic_structures.html?highlight=3Dcvreleaseimage#releaseim=
age</a></div><div><br></div><div>I guess you could do it with a lambda but =
then you actually need a way to reference the resource itself to take its a=
ddress.</div><div>Also, writing this lambda every time is tedious and error=
 prone as this is quite a common API approach.</div><div><br></div><div>Adi=
</div></div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_762_31022966.1390720573144--

.