Topic: n4023: Apply function is not working with member pointers


Author: tomaszkam@gmail.com
Date: Sun, 6 Jul 2014 14:29:49 -0700 (PDT)
Raw View
------=_Part_335_19893314.1404682189645
Content-Type: text/plain; charset=UTF-8

In the paper N4023
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4023.html> there
is definition of apply() functions that allows to call a function with a
tuple of arguments. Currently it is definied as follows:

template <class F, class Tuple>
constexpr decltype(auto) apply(F&& f, Tuple&& t);


Effects:

Given the exposition only function

template <class F, class Tuple, size_t... I>
constexpr decltype(auto) apply_impl(  // *exposition only*
    F&& f, Tuple&& t, index_sequence<I...>) {
  return std::forward<F>(f)(std::get<I>(std::forward<Tuple>(t))...);
}

Equivalent to

return apply_impl(std::forward<F>(f), std::forward<Tuple>(t),
    make_index_sequence<tuple_size<decay_t<Tuple>>::value>{});


Having the following definition the apply functions is working with
function objects and function pointers, but does not work with pointer to
members which is acepted by rest of the standard librarary.

I think that definition should be changed to:

template <class F, class Tuple>
constexpr decltype(auto) apply(F&& f, Tuple&& t);


Effects: Equivalent to INOVKE(std::forward<F>(f),
std::get<0>(std::forward<Tuple>(t)), ...,
std::get<N-1>(std::forward<Tuple>(t)), where N is the value of

tuple_size_v<decay_t<Tuple>>.


--

---
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_335_19893314.1404682189645
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">In the paper <a href=3D"http://www.open-std.org/jtc1/sc22/=
wg21/docs/papers/2014/n4023.html">N4023</a> there is definition of apply() =
functions that allows to call a function with a tuple of arguments. Current=
ly it is definied as follows:<br>
   =20
    <pre><code>template &lt;class F, class Tuple&gt;
constexpr decltype(auto) apply(F&amp;&amp; f, Tuple&amp;&amp; t);</code></p=
re>

    <dl><dt><br></dt><dt>Effects:</dt><dd>
          <p>Given the exposition only function</p>
          <pre><code>template &lt;class F, class Tuple, size_t... I&gt;
constexpr decltype(auto) apply_impl(  // <i>exposition only</i>
    F&amp;&amp; f, Tuple&amp;&amp; t, index_sequence&lt;I...&gt;) {
  return std::forward&lt;F&gt;(f)(std::get&lt;I&gt;(std::forward&lt;Tuple&g=
t;(t))...);
}</code></pre>
          <p>Equivalent to</p>
          <pre><code>return apply_impl(std::forward&lt;F&gt;(f), std::forwa=
rd&lt;Tuple&gt;(t),
    make_index_sequence&lt;tuple_size&lt;decay_t&lt;Tuple&gt;&gt;::value&gt=
;{});</code></pre>
        </dd></dl>
  <br>Having the following definition the apply functions is working with f=
unction objects and function pointers, but does not work with pointer to me=
mbers which is acepted by rest of the standard librarary. <br><br>I think t=
hat definition should be changed to:<br><pre><code>template &lt;class F, cl=
ass Tuple&gt;
constexpr decltype(auto) apply(F&amp;&amp; f, Tuple&amp;&amp; t);</code></p=
re>

    <dl><dt><br></dt><dt>Effects: Equivalent to INOVKE(<code>std::forward&l=
t;F&gt;(f),</code><code> std::get&lt;0&gt;(std::forward&lt;Tuple&gt;(t)), .=
..., </code><code><code>std::get&lt;N-1&gt;(std::forward&lt;Tuple&gt;(t)</co=
de>), where N is the value of </code><br></dt></dl><pre><code>tuple_size_v&=
lt;decay_t&lt;Tuple&gt;&gt;.</code></pre><br></div>

<p></p>

-- <br />
<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 <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 />
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_335_19893314.1404682189645--

.


Author: Zhihao Yuan <zy@miator.net>
Date: Sun, 6 Jul 2014 18:43:29 -0400
Raw View
--047d7b677a1a66603e04fd8e1606
Content-Type: text/plain; charset=UTF-8

On Sun, Jul 6, 2014 at 5:29 PM, <tomaszkam@gmail.com> wrote:

> Effects: Equivalent to INOVKE(std::forward<F>(f),
> std::get<0>(std::forward<Tuple>(t)), ...,
> std::get<N-1>(std::forward<Tuple>(t)), where N is the value of
>
> tuple_size_v<decay_t<Tuple>>.
>
>
Agreed.  File a library issue please.


--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://bit.ly/blog4bsd

--

---
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/.

--047d7b677a1a66603e04fd8e1606
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Sun, Jul 6, 2014 at 5:29 PM,  <span dir=3D"ltr">&lt;<a =
href=3D"mailto:tomaszkam@gmail.com" target=3D"_blank">tomaszkam@gmail.com</=
a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_quot=
e"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bord=
er-left:1px solid rgb(204,204,204);padding-left:1ex">

<div dir=3D"ltr"><dl><dt>Effects: Equivalent to INOVKE(<code>std::forward&l=
t;F&gt;(f),</code><code> std::get&lt;0&gt;(std::forward&lt;Tuple&gt;(t)), .=
..., </code><code><code>std::get&lt;N-1&gt;(std::forward&lt;Tuple&gt;(t)</co=
de>), where N is the value of </code><br>

</dt></dl><pre><code>tuple_size_v&lt;decay_t&lt;Tuple&gt;&gt;.</code></pre>=
<span></span></div></blockquote></div><br></div><div class=3D"gmail_extra">=
Agreed.=C2=A0 File a library issue please.<br></div><div class=3D"gmail_ext=
ra">
<br clear=3D"all"></div>
<div class=3D"gmail_extra"><br>-- <br>Zhihao Yuan, ID lichray<br>The best w=
ay to predict the future is to invent it.<br>______________________________=
_____________________<br>4BSD -- <a href=3D"http://bit.ly/blog4bsd" target=
=3D"_blank">http://bit.ly/blog4bsd</a>
</div></div>

<p></p>

-- <br />
<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 <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 />
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 />

--047d7b677a1a66603e04fd8e1606--

.


Author: tomaszkam@gmail.com
Date: Sun, 6 Jul 2014 21:54:28 -0700 (PDT)
Raw View
------=_Part_821_24050578.1404708868282
Content-Type: text/plain; charset=UTF-8

 Reposting original post, at it is no longer visible in Future Proposlas
group.

The definition of the apply() function present in $3.2.2 [tupple.apply] of
N4023 <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4023.html>:
Working Draft, C++ Extensions for Library Fundamentals prevents this
function template to be used with pointer to members type passed as the
first argument.

template <class F, class Tuple>
constexpr decltype(auto) apply(F&& f, Tuple&& t);


Effects:

Given the exposition only function

template <class F, class Tuple, size_t... I>
constexpr decltype(auto) apply_impl(  // *exposition only*
    F&& f, Tuple&& t, index_sequence<I...>) {
  return std::forward<F>(f)(std::get<I>(std::forward<Tuple>(t))...);
}

Equivalent to

return apply_impl(std::forward<F>(f), std::forward<Tuple>(t),
    make_index_sequence<tuple_size<decay_t<Tuple>>::value>{});

 This makes this functions non-consistent with other standard library
components and limits its usability.

I think that definition should be changed to:

template <class F, class Tuple>
constexpr decltype(auto) apply(F&& f, Tuple&& t);


Effects: Equivalent to INOVKE(std::forward<F>(f),
std::get<0>(std::forward<Tuple>(t)), ...,
std::get<N-1>(std::forward<Tuple>(t)),
      where N is the value of tuple_size_v<decay_t<Tuple>>.

--

---
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_821_24050578.1404708868282
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">
 =20
 =20
    Reposting original post, at it is no longer visible in Future Proposlas=
 group.<br><br>The definition of the apply() function present in $<span cla=
ss=3D"section-number">3.2.2</span> [tupple.apply] of <a moz-do-not-send=3D"=
true" href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4023=
..html">N4023</a>:
    Working Draft, C++ Extensions for Library Fundamentals prevents this
    function template to be used with pointer to members type passed as
    the first argument. <br>
    <pre><code>template &lt;class F, class Tuple&gt;
constexpr decltype(auto) apply(F&amp;&amp; f, Tuple&amp;&amp; t);</code></p=
re>
    <dl><dt><br>
      </dt><dt>Effects:</dt><dd>
        <p>Given the exposition only function</p>
        <pre><code>template &lt;class F, class Tuple, size_t... I&gt;
constexpr decltype(auto) apply_impl(  // <i>exposition only</i>
    F&amp;&amp; f, Tuple&amp;&amp; t, index_sequence&lt;I...&gt;) {
  return std::forward&lt;F&gt;(f)(std::get&lt;I&gt;(std::forward&lt;Tuple&g=
t;(t))...);
}</code></pre>
        <p>Equivalent to</p>
        <pre><code>return apply_impl(std::forward&lt;F&gt;(f), std::forward=
&lt;Tuple&gt;(t),
    make_index_sequence&lt;tuple_size&lt;decay_t&lt;Tuple&gt;&gt;::value&gt=
;{});</code></pre>
      </dd></dl>
    This makes this functions non-consistent with other standard library co=
mponents and limits its usability.<br>
    <br>
    I think that definition should be changed to:<br>
    <pre><code>template &lt;class F, class Tuple&gt;
constexpr decltype(auto) apply(F&amp;&amp; f, Tuple&amp;&amp; t);</code></p=
re>
    <dl><dt><br>
      </dt><dt>Effects: Equivalent to INOVKE(<code>std::forward&lt;F&gt;(f)=
,</code><code>
          std::get&lt;0&gt;(std::forward&lt;Tuple&gt;(t)), ..., </code><cod=
e><code>std::get&lt;N-1&gt;(std::forward&lt;Tuple&gt;(t)</code>), <br></cod=
e></dt><dt><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where N is the value of</co=
de><code> tuple_size_v&lt;decay_t&lt;Tuple&gt;&gt;.</code></dt></dl></div>

<p></p>

-- <br />
<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 <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 />
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_821_24050578.1404708868282--

.


Author: Zhihao Yuan <zy@miator.net>
Date: Mon, 6 Oct 2014 10:41:06 -0400
Raw View
--001a11347a0aa051e80504c212ef
Content-Type: text/plain; charset=UTF-8

On Mon, Jul 7, 2014 at 12:54 AM, <tomaszkam@gmail.com> wrote:

> Reposting original post, at it is no longer visible in Future Proposlas
> group.
>
> The definition of the apply() function present in $3.2.2 [tupple.apply]
> of N4023
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4023.html>:
> Working Draft, C++ Extensions for Library Fundamentals prevents this
> function template to be used with pointer to members type passed as the
> first argument.
>
> template <class F, class Tuple>
> constexpr decltype(auto) apply(F&& f, Tuple&& t);
>
>
> Effects:
>
> Given the exposition only function
>
> template <class F, class Tuple, size_t... I>
> constexpr decltype(auto) apply_impl(  // *exposition only*
>     F&& f, Tuple&& t, index_sequence<I...>) {
>   return std::forward<F>(f)(std::get<I>(std::forward<Tuple>(t))...);
> }
>
> Equivalent to
>
> return apply_impl(std::forward<F>(f), std::forward<Tuple>(t),
>     make_index_sequence<tuple_size<decay_t<Tuple>>::value>{});
>
>  This makes this functions non-consistent with other standard library
> components and limits its usability.
>
> I think that definition should be changed to:
>
> template <class F, class Tuple>
> constexpr decltype(auto) apply(F&& f, Tuple&& t);
>
>
> Effects: Equivalent to INOVKE(std::forward<F>(f),
> std::get<0>(std::forward<Tuple>(t)), ...,
> std::get<N-1>(std::forward<Tuple>(t)),
>       where N is the value of tuple_size_v<decay_t<Tuple>>.
>
> Issue filed: http://cplusplus.github.io/LWG/lwg-active.html#2418

But I'm still using the old style wording (utilizing index_sequence),
because I found the N == 0 is hard to explain (though we all know
the effect).  If someone want a simpler wording, we can do it
during the meeting.

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://bit.ly/blog4bsd

--

---
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/.

--001a11347a0aa051e80504c212ef
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Mon, Jul 7, 2014 at 12:54 AM,  <span dir=3D"ltr">&lt;<a=
 href=3D"mailto:tomaszkam@gmail.com" target=3D"_blank">tomaszkam@gmail.com<=
/a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_quo=
te"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">
 =20
 =20
    Reposting original post, at it is no longer visible in Future Proposlas=
 group.<br><br>The definition of the apply() function present in $<span>3.2=
..2</span> [tupple.apply] of <a href=3D"http://www.open-std.org/jtc1/sc22/wg=
21/docs/papers/2014/n4023.html" target=3D"_blank">N4023</a>:
    Working Draft, C++ Extensions for Library Fundamentals prevents this
    function template to be used with pointer to members type passed as
    the first argument. <br><span class=3D"">
    <pre><code>template &lt;class F, class Tuple&gt;
constexpr decltype(auto) apply(F&amp;&amp; f, Tuple&amp;&amp; t);</code></p=
re>
    <dl><dt><br>
      </dt><dt>Effects:</dt><dd>
        <p>Given the exposition only function</p>
        <pre><code>template &lt;class F, class Tuple, size_t... I&gt;
constexpr decltype(auto) apply_impl(  // <i>exposition only</i>
    F&amp;&amp; f, Tuple&amp;&amp; t, index_sequence&lt;I...&gt;) {
  return std::forward&lt;F&gt;(f)(std::get&lt;I&gt;(std::forward&lt;Tuple&g=
t;(t))...);
}</code></pre>
        <p>Equivalent to</p>
        <pre><code>return apply_impl(std::forward&lt;F&gt;(f), std::forward=
&lt;Tuple&gt;(t),
    make_index_sequence&lt;tuple_size&lt;decay_t&lt;Tuple&gt;&gt;::value&gt=
;{});</code></pre>
      </dd></dl></span>
    This makes this functions non-consistent with other standard library co=
mponents and limits its usability.<span class=3D""><br>
    <br>
    I think that definition should be changed to:<br>
    <pre><code>template &lt;class F, class Tuple&gt;
constexpr decltype(auto) apply(F&amp;&amp; f, Tuple&amp;&amp; t);</code></p=
re>
    </span><dl><dt><br>
      </dt><span class=3D""><dt>Effects: Equivalent to INOVKE(<code>std::fo=
rward&lt;F&gt;(f),</code><code>
          std::get&lt;0&gt;(std::forward&lt;Tuple&gt;(t)), ..., </code><cod=
e><code>std::get&lt;N-1&gt;(std::forward&lt;Tuple&gt;(t)</code>), <br></cod=
e></dt><dt><code>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 where N is the value of</co=
de><code> tuple_size_v&lt;decay_t&lt;Tuple&gt;&gt;.</code></dt></span></dl>=
</div>

<p></p></blockquote></div>Issue filed: <a href=3D"http://cplusplus.github.i=
o/LWG/lwg-active.html#2418">http://cplusplus.github.io/LWG/lwg-active.html#=
2418</a><br><br></div><div class=3D"gmail_extra">But I&#39;m still using th=
e old style wording (utilizing index_sequence),<br></div><div class=3D"gmai=
l_extra">because I found the N =3D=3D 0 is hard to explain (though we all k=
now<br></div><div class=3D"gmail_extra">the effect).=C2=A0 If someone want =
a simpler wording, we can do it<br></div><div class=3D"gmail_extra">during =
the meeting.<br clear=3D"all"></div><div class=3D"gmail_extra"><br>-- <br>Z=
hihao Yuan, ID lichray<br>The best way to predict the future is to invent i=
t.<br>___________________________________________________<br>4BSD -- <a hre=
f=3D"http://bit.ly/blog4bsd" target=3D"_blank">http://bit.ly/blog4bsd</a>
</div></div>

<p></p>

-- <br />
<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 <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 />
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 />

--001a11347a0aa051e80504c212ef--

.