Topic: function_ref
Author: Avi Kivity <avi@scylladb.com>
Date: Fri, 9 Dec 2016 16:19:37 +0200
Raw View
Often, one wants to call a function with a one-off callback. There are
currently three ways to do this:
1. templates
template <typename Func> // void (int, int)
void foo(int a, int b, Func func);
The problem here is that foo's definition must be available, and there
is an increase in compile time, executable size, and the odds of seeing
a cryptic error (to be reduced with concepts).
2. std::function
void foo(int a, int b, std::function<void (int, int)> func);
We've solved the problems of the template above, but added a virtual
function call, an allocation (which can be avoided be the
implementation, sometimes), and a requirement that the lambda we send
here be copyable; if we pass func down the line, we add either extra
indirection or extra copies/allocations.
3. custom abstract class
class foo_callback {
public:
virtual ~foo_callback() {} // not really necessary
virtual void call(int, int) const = 0;
};
void foo(int a, int b, const foo_callback& func);
This is the C++98 way; it is very verbose for the caller, but avoids any
allocation for the caller, and can be passed efficiently downstream.
I'm proposing a fourth way, std::function_ref. It acts like
std::function, but only refers to a function; it does not capture the
value. It is the responsibility of the caller to ensure the function is
alive.
void foo(int a, int b, std::function_ref<void (int a, int b)> func);
Here's a sample program:
void sum_and_report(int a, int b, function_ref<void (int sum)> report) {
report(a + b);
}
int main(int ac, char** av) {
int sum;
sum_and_report(2, 2, [&] (int result) {
sum = result;
});
return sum == 4 ? 0 : 1;
}
and here's an example implementation:
template <typename Ret, typename... Args>
class function_ref<Ret (Args...)> {
using thunk_type = Ret (*)(const function_ref*, Args...);
const void* _lambda;
thunk_type _thunk;
public:
template <typename Lambda>
function_ref(const Lambda& lambda)
: _lambda(&lambda) {
_thunk = thunk_type([] (const function_ref* zis, Args... args) {
auto lambda = static_cast<const Lambda*>(zis->_lambda);
return (*lambda)(std::move(args)...);
});
}
Ret operator()(Args... args) const {
return _thunk(this, std::move(args)...);
}
};
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/991fac53-0c25-4a20-9b78-57628fed8027%40scylladb.com.
.
Author: Zhihao Yuan <zy@miator.net>
Date: Fri, 9 Dec 2016 09:36:23 -0600
Raw View
On Fri, Dec 9, 2016 at 8:19 AM, Avi Kivity <avi@scylladb.com> wrote:
>
> I'm proposing a fourth way, std::function_ref. It acts like std::function,
> but only refers to a function; it does not capture the value. It is the
> responsibility of the caller to ensure the function is alive.
>
>
> void foo(int a, int b, std::function_ref<void (int a, int b)> func);
See also http://blog.miator.net/post/141640032964/take-callable-by-signature-rargs
, with a few changes on top of the LLVM function_ref. Not proposed
yet, but I think it's a good idea.
--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://blog.miator.net/
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGsORuC0%3DjudwW-iUXjBCvHjJbtz7%3DAHfxU79OOA5bVU2TeqyA%40mail.gmail.com.
.
Author: "D. B." <db0451@gmail.com>
Date: Fri, 9 Dec 2016 16:13:04 +0000
Raw View
--001a11443f0c6706f605433c0781
Content-Type: text/plain; charset=UTF-8
I thought that std::function combined with std::reference_wrapper would
already handle this case. Where does it fall short?
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhFkvr%2BT2EMK_GdrmXZWa6JehgD%2BmNf7HqXzOrckJ%2B3uMw%40mail.gmail.com.
--001a11443f0c6706f605433c0781
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I thought that std::function combined with std::reference_=
wrapper would already handle this case. Where does it fall short?<br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhFkvr%2BT2EMK_GdrmXZWa6JehgD%2B=
mNf7HqXzOrckJ%2B3uMw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhFkvr=
%2BT2EMK_GdrmXZWa6JehgD%2BmNf7HqXzOrckJ%2B3uMw%40mail.gmail.com</a>.<br />
--001a11443f0c6706f605433c0781--
.
Author: Avi Kivity <avi@scylladb.com>
Date: Fri, 9 Dec 2016 18:20:08 +0200
Raw View
--001a114c9f8eb7344a05433c20f1
Content-Type: text/plain; charset=UTF-8
It allocates (perhaps conditionally in some implementations).
On Dec 9, 2016 18:13, "D. B." <db0451@gmail.com> wrote:
I thought that std::function combined with std::reference_wrapper would
already handle this case. Where does it fall short?
--
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.
To view this discussion on the web visit https://groups.google.com/a/
isocpp.org/d/msgid/std-proposals/CACGiwhFkvr%2BT2EMK_GdrmXZWa6JehgD%
2BmNf7HqXzOrckJ%2B3uMw%40mail.gmail.com
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhFkvr%2BT2EMK_GdrmXZWa6JehgD%2BmNf7HqXzOrckJ%2B3uMw%40mail.gmail.com?utm_medium=email&utm_source=footer>
..
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAF950WLsb9CRqwsLFZumEy-vyFZSHnZOuXUB3_-q0U51AXVnAQ%40mail.gmail.com.
--001a114c9f8eb7344a05433c20f1
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"auto"><div>It allocates (perhaps conditionally in some implemen=
tations).<br><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On D=
ec 9, 2016 18:13, "D. B." <<a href=3D"mailto:db0451@gmail.com"=
>db0451@gmail.com</a>> wrote:<br type=3D"attribution"><blockquote class=
=3D"quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><div dir=3D"ltr">I thought that std::function combined with std::re=
ference_wrapper would already handle this case. Where does it fall short?<b=
r></div><div class=3D"quoted-text">
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhFkvr%2BT2EMK_GdrmXZWa6JehgD%2B=
mNf7HqXzOrckJ%2B3uMw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Df=
ooter" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgi=
d/std-<wbr>proposals/CACGiwhFkvr%2BT2EMK_<wbr>GdrmXZWa6JehgD%<wbr>2BmNf7HqX=
zOrckJ%2B3uMw%40mail.<wbr>gmail.com</a>.<br>
</blockquote></div><br></div></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAF950WLsb9CRqwsLFZumEy-vyFZSHnZOuXUB=
3_-q0U51AXVnAQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAF950WLsb9CRqwsL=
FZumEy-vyFZSHnZOuXUB3_-q0U51AXVnAQ%40mail.gmail.com</a>.<br />
--001a114c9f8eb7344a05433c20f1--
.
Author: Avi Kivity <avi@scylladb.com>
Date: Fri, 9 Dec 2016 18:31:08 +0200
Raw View
--001a113f1f0c0011a505433c486d
Content-Type: text/plain; charset=UTF-8
Yes, llvm function_ref and mine are very similar. So it looks like there's
a case for standardization.
On Dec 9, 2016 17:36, "Zhihao Yuan" <zy@miator.net> wrote:
> On Fri, Dec 9, 2016 at 8:19 AM, Avi Kivity <avi@scylladb.com> wrote:
> >
> > I'm proposing a fourth way, std::function_ref. It acts like
> std::function,
> > but only refers to a function; it does not capture the value. It is the
> > responsibility of the caller to ensure the function is alive.
> >
> >
> > void foo(int a, int b, std::function_ref<void (int a, int b)> func);
>
> See also http://blog.miator.net/post/141640032964/take-callable-by-
> signature-rargs
> , with a few changes on top of the LLVM function_ref. Not proposed
> yet, but I think it's a good idea.
>
> --
> Zhihao Yuan, ID lichray
> The best way to predict the future is to invent it.
> ___________________________________________________
> 4BSD -- http://blog.miator.net/
>
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/CAGsORuC0%3DjudwW-iUXjBCvHjJbtz7%
> 3DAHfxU79OOA5bVU2TeqyA%40mail.gmail.com.
>
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAF950WJdDSjwBG7pGQjS_JysKyCzs9Ka-173QDGGQEBBH2xqtA%40mail.gmail.com.
--001a113f1f0c0011a505433c486d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"auto">Yes, llvm function_ref and mine are very similar. So it l=
ooks like there's a case for standardization.</div><div class=3D"gmail_=
extra"><br><div class=3D"gmail_quote">On Dec 9, 2016 17:36, "Zhihao Yu=
an" <<a href=3D"mailto:zy@miator.net">zy@miator.net</a>> wrote:<=
br type=3D"attribution"><blockquote class=3D"gmail_quote" style=3D"margin:0=
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, Dec 9, 2016 =
at 8:19 AM, Avi Kivity <<a href=3D"mailto:avi@scylladb.com">avi@scylladb=
..com</a>> wrote:<br>
><br>
> I'm proposing a fourth way, std::function_ref.=C2=A0 It acts like =
std::function,<br>
> but only refers to a function; it does not capture the value.=C2=A0 It=
is the<br>
> responsibility of the caller to ensure the function is alive.<br>
><br>
><br>
>=C2=A0 =C2=A0void foo(int a, int b, std::function_ref<void (int a, i=
nt b)> func);<br>
<br>
See also <a href=3D"http://blog.miator.net/post/141640032964/take-callable-=
by-signature-rargs" rel=3D"noreferrer" target=3D"_blank">http://blog.miator=
..net/post/<wbr>141640032964/take-callable-by-<wbr>signature-rargs</a><br>
, with a few changes on top of the LLVM function_ref.=C2=A0 Not proposed<br=
>
yet, but I think it's a good idea.<br>
<br>
--<br>
Zhihao Yuan, ID lichray<br>
The best way to predict the future is to invent it.<br>
______________________________<wbr>_____________________<br>
4BSD -- <a href=3D"http://blog.miator.net/" rel=3D"noreferrer" target=3D"_b=
lank">http://blog.miator.net/</a><br>
<br>
--<br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org">std-propo=
sals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAGsORuC0%3DjudwW-iUXjBCvHjJbtz7%3DAH=
fxU79OOA5bVU2TeqyA%40mail.gmail.com" rel=3D"noreferrer" target=3D"_blank">h=
ttps://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/CAGsO=
RuC0%3DjudwW-<wbr>iUXjBCvHjJbtz7%<wbr>3DAHfxU79OOA5bVU2TeqyA%40mail.<wbr>gm=
ail.com</a>.<br>
</blockquote></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAF950WJdDSjwBG7pGQjS_JysKyCzs9Ka-173=
QDGGQEBBH2xqtA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAF950WJdDSjwBG7p=
GQjS_JysKyCzs9Ka-173QDGGQEBBH2xqtA%40mail.gmail.com</a>.<br />
--001a113f1f0c0011a505433c486d--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Fri, 9 Dec 2016 08:32:08 -0800 (PST)
Raw View
------=_Part_416_215145233.1481301128475
Content-Type: multipart/alternative;
boundary="----=_Part_417_485296002.1481301128475"
------=_Part_417_485296002.1481301128475
Content-Type: text/plain; charset=UTF-8
On Friday, December 9, 2016 at 11:13:06 AM UTC-5, D. B. wrote:
>
> I thought that std::function combined with std::reference_wrapper would
> already handle this case. Where does it fall short?
>
1. There's no way to *prevent* someone from passing something that *isn't*
bound in `reference_wrapper`.
2. The combination of `function` with `reference_wrapper` is not
particularly obvious. As such, it will primarily be used by experts, rather
than lay C++ users.
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/17fe6027-8690-44a7-8339-110a6528d84a%40isocpp.org.
------=_Part_417_485296002.1481301128475
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Friday, December 9, 2016 at 11:13:06 AM UTC-5, D. B. wr=
ote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">I thought=
that std::function combined with std::reference_wrapper would already hand=
le this case. Where does it fall short?<br></div></blockquote><div><br>1. T=
here's no way to <i>prevent</i> someone from passing something that <i>=
isn't</i> bound in `reference_wrapper`.<br><br>2. The combination of `f=
unction` with `reference_wrapper` is not particularly obvious. As such, it =
will primarily be used by experts, rather than lay C++ users.<br></div></di=
v>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/17fe6027-8690-44a7-8339-110a6528d84a%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/17fe6027-8690-44a7-8339-110a6528d84a=
%40isocpp.org</a>.<br />
------=_Part_417_485296002.1481301128475--
------=_Part_416_215145233.1481301128475--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Fri, 9 Dec 2016 08:33:23 -0800 (PST)
Raw View
------=_Part_684_951860142.1481301203614
Content-Type: multipart/alternative;
boundary="----=_Part_685_1297877882.1481301203614"
------=_Part_685_1297877882.1481301203614
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Friday, December 9, 2016 at 11:20:11 AM UTC-5, Avi Kivity wrote:
>
> It allocates (perhaps conditionally in some implementations).
>
From the standard:
> shall not throw exceptions if f =E2=80=99s target is a callable object p=
assed=20
via reference_wrapper or a function pointer.
So it's not allowed to allocate memory.
--=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/bfbd9c76-0adf-4922-a36d-71233d803235%40isocpp.or=
g.
------=_Part_685_1297877882.1481301203614
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Friday, December 9, 2016 at 11:20:11 AM UTC-5, Avi Kivi=
ty wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: =
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"auto"><di=
v>It allocates (perhaps conditionally in some implementations).<br></div></=
div></blockquote><div><br>From the standard:<br><br>>=C2=A0 shall not th=
row exceptions if f =E2=80=99s target is a callable object passed via refer=
ence_wrapper or a function pointer.<br><br>So it's not allowed to alloc=
ate memory.</div><br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/bfbd9c76-0adf-4922-a36d-71233d803235%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/bfbd9c76-0adf-4922-a36d-71233d803235=
%40isocpp.org</a>.<br />
------=_Part_685_1297877882.1481301203614--
------=_Part_684_951860142.1481301203614--
.
Author: Avi Kivity <avi@scylladb.com>
Date: Sat, 10 Dec 2016 00:45:57 +0200
Raw View
This is a multi-part message in MIME format.
--------------6A940B38693D216B1033ABB5
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
On 12/09/2016 06:33 PM, Nicol Bolas wrote:
> On Friday, December 9, 2016 at 11:20:11 AM UTC-5, Avi Kivity wrote:
>
> It allocates (perhaps conditionally in some implementations).
>
>
> From the standard:
>
> > shall not throw exceptions if f =E2=80=99s target is a callable object=
=20
> passed via reference_wrapper or a function pointer.
>
> So it's not allowed to allocate memory.
>
Interesting. That makes the proposal less compelling.
--=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/acd6090c-0500-3299-8b38-48f49b4c88c0%40scylladb.=
com.
--------------6A940B38693D216B1033ABB5
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
<div class=3D"moz-cite-prefix">On 12/09/2016 06:33 PM, Nicol Bolas
wrote:<br>
</div>
<blockquote
cite=3D"mid:bfbd9c76-0adf-4922-a36d-71233d803235@isocpp.org"
type=3D"cite">
<div dir=3D"ltr">On Friday, December 9, 2016 at 11:20:11 AM UTC-5,
Avi Kivity wrote:
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<div dir=3D"auto">
<div>It allocates (perhaps conditionally in some
implementations).<br>
</div>
</div>
</blockquote>
<div><br>
From the standard:<br>
<br>
>=C2=A0 shall not throw exceptions if f =E2=80=99s target is a=
callable
object passed via reference_wrapper or a function pointer.<br>
<br>
So it's not allowed to allocate memory.</div>
<br>
</div>
</blockquote>
<br>
Interesting.=C2=A0 That makes the proposal less compelling.<br>
</body>
</html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/acd6090c-0500-3299-8b38-48f49b4c88c0%=
40scylladb.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.googl=
e.com/a/isocpp.org/d/msgid/std-proposals/acd6090c-0500-3299-8b38-48f49b4c88=
c0%40scylladb.com</a>.<br />
--------------6A940B38693D216B1033ABB5--
.
Author: Zhihao Yuan <zy@miator.net>
Date: Sat, 10 Dec 2016 00:13:26 -0600
Raw View
On Fri, Dec 9, 2016 at 4:45 PM, Avi Kivity <avi@scylladb.com> wrote:
>
> Interesting. That makes the proposal less compelling.
This is arguable. function_ref as a vocabulary type, embeds the
meaning of non-owning into the type itself rather than ask the
caller side to choose, IMO is semantically independent,
regardless of lots of other advantages in terms of compilation
time, codegen, etc.
--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://blog.miator.net/
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGsORuDj6W2YFA9OZSfnT9CFbpzwB_UXpsAbVS04wghL_r7NKQ%40mail.gmail.com.
.
Author: Avi Kivity <avi@scylladb.com>
Date: Sat, 10 Dec 2016 11:19:00 +0200
Raw View
On 12/10/2016 08:13 AM, Zhihao Yuan wrote:
> On Fri, Dec 9, 2016 at 4:45 PM, Avi Kivity <avi@scylladb.com> wrote:
>> Interesting. That makes the proposal less compelling.
> This is arguable. function_ref as a vocabulary type, embeds the
> meaning of non-owning into the type itself rather than ask the
> caller side to choose, IMO is semantically independent,
> regardless of lots of other advantages in terms of compilation
> time, codegen, etc.
>
I'm not saying the proposal is worthless, just that it is less
compelling. It still has advantages over function_ref, but they are
smaller than what I thought they were.
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/03e36423-53d5-ad96-1624-b2b1717a8c8c%40scylladb.com.
.