Topic: std::apply overload with extra arguments
Author: dan@soundradix.com
Date: Wed, 27 Dec 2017 01:50:01 -0800 (PST)
Raw View
------=_Part_20761_2145630912.1514368201892
Content-Type: multipart/alternative;
boundary="----=_Part_20762_740846800.1514368201894"
------=_Part_20762_740846800.1514368201894
Content-Type: text/plain; charset="UTF-8"
Hi,
I've made an overload of std::apply which takes extra fixed parameters, and
was wondering if it would be of enough interest to make for a proposal.
The overload is:
// Similar to std::apply but accepts extra arguments
namespace detail {
template <class F, class Tuple, std::size_t... I, typename... ExtraArgs>
constexpr decltype(auto) apply_impl(F&& f, Tuple&& t, std::index_sequence<I
....>, ExtraArgs&&... args)
{
return std::invoke(std::forward<F>(f), args..., std::get<I>(std::forward<
Tuple>(t))...);
}
} // namespace detail
template <class F, class Tuple, typename... ExtraArgs>
constexpr decltype(auto) apply(F&& f, Tuple&& t, ExtraArgs&&... args)
{
return detail::apply_impl(
std::forward<F>(f), std::forward<Tuple>(t),
std::make_index_sequence<std::tuple_size_v<std::remove_reference_t<
Tuple>>>{},
args...);
}
and is just a tweaked version of the sample implementation
<http://en.cppreference.com/w/cpp/utility/apply> shown in cppreference.
More details:
I've come across a situation where I wanted to apply a function to a tuple
after mapping it using a member function.
If the member function takes no parameters, this can be done using the
existing std::apply:
template<typename F, typename... Is>
class C
{
public:
C(std::tuple<Is&...>, F&&);
auto call_f();
private:
auto call_f_helper(Is&...);
private:
std::tuple<Is&...> inputs;
F f;
};
template<typename F, typename... Is>
auto C<F, Is...>::call_f()
{
return std::apply(&call_f_helper, inputs);
}
template<typename F, typename... Is>
auto C<F, Is...>::call_f_helper(Is&... inputs_unpacked)
{
return F(inputs_unpacked.member_func()...);
}
But if the member function does take parameters, then assuming we want to
pass in the same parameters to all the calls to member_func, there is no
way to pass them through with std::apply.
More generally, given a callable which takes some fixed parameters followed
by a parameter pack, there is no way to use std::apply to call the function
with the tuple mapped into the parameter pack and pass some other arguments
into the fixed parameters.
The suggested new overload allows modifying the example to work with member
functions that take parameters:
template<typename F, typename... Is>
auto C<F, Is...>::call_f(int arg1, double arg2)
{
return std::apply(&call_f_helper, inputs, arg1, arg2);
}
template<typename F, typename... Is>
auto C<F, Is...>::call_f_helper(int arg1, double arg2, Is&...
inputs_unpacked)
{
return F(inputs_unpacked.member_func(arg1, arg2)...);
}
Other alternatives that could work, and wouldn't require a new overload for
std::apply:
- Concatenating the fixed arguments the beginning of the inputs tuple, and
calling std::apply on that tuple.
- Mapping the inputs tuple to a new tuple of tuples, each tuple containing
an input an its fixed arguments, and calling std::apply on that.
Still, I was curious whether the new overload of std::tuple would be
interesting enough to warrant its (or something similar's) addition to the
standard.
Thanks,
Dan
--
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/5be671fa-c36e-4aed-9409-c7342de0d3b4%40isocpp.org.
------=_Part_20762_740846800.1514368201894
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi,<div><br></div><div>I've made an overload of std::a=
pply which takes extra fixed parameters, and was wondering if it would be o=
f enough interest to make for a proposal.<div><div><br></div><div>The overl=
oad is:</div><div><br></div><div><div class=3D"prettyprint" style=3D"border=
: 1px solid rgb(187, 187, 187); background-color: rgb(250, 250, 250); word-=
wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint=
"><span style=3D"color: #800;" class=3D"styled-by-prettify">// Similar to s=
td::apply but accepts extra arguments </span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">namespace</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> detail </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> <br></span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">template</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> F</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">class</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Tuple</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">size=
_t</span><span style=3D"color: #660;" class=3D"styled-by-prettify">...</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> I</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">...</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">ExtraArgs</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> <br></span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">constexpr</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">declty=
pe</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> apply_impl</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">F</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&&</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> f</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
Tuple</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
&</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> t</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">index_sequence</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify">I</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">...>,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"sty=
led-by-prettify">ExtraArgs</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&&...</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> args</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> <br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <br>=C2=
=A0 =C2=A0</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
return</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">invoke</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">std</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">forward</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">F</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">>(</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">),<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> args</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">...,</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">get</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">I</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">>(</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">std</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">for=
ward</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</=
span><span style=3D"color: #606;" class=3D"styled-by-prettify">Tuple</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">>(</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify">t</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">))...);</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> <br></span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> <br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-pret=
tify">// namespace detail </span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">template</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y"><</span><span style=3D"color: #008;" class=3D"styled-by-prettify">cla=
ss</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> F</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">class</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" cl=
ass=3D"styled-by-prettify">Tuple</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">typename</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">...</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #606;" class=3D"styled-by-prettify">ExtraArgs</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">></span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> <br></span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">decltype</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">auto</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> apply</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">F</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&&a=
mp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> f</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #606;" class=3D"styled-by-prettify">Tuple</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">&&</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> t</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by=
-prettify">ExtraArgs</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">&&...</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> args</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> <br>=C2=A0 =C2=
=A0</span><span style=3D"color: #008;" class=3D"styled-by-prettify">return<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> detail</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify">apply_impl</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> <br>=C2=A0 =C2=A0 =C2=A0 std</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">forward</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">F</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">>(</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">f</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">),</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">forward</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Tuple</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">>(</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">t</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">),</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> <br>=C2=A0 =C2=A0 =C2=A0 std</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">make_index_sequence</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">std</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">tuple_size_v</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">remove_reference_t</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify"><</span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Tuple</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">>>>{},</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> <br>=C2=A0 =C2=A0 =C2=A0 args</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">...);</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> <br></span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">}</span></div></code></div></div><div><br=
></div><div>and is just a tweaked version of the <a href=3D"http://en.cppre=
ference.com/w/cpp/utility/apply">sample implementation</a> shown in cpprefe=
rence.</div><div><br></div><div>More details:</div><div><br></div><div>I=
9;ve come across a situation where I wanted to apply a function to a tuple =
after mapping it using a member function.<div>If the member function takes =
no parameters, this can be done using the existing std::apply:<br><div><br>=
</div><div></div></div><div class=3D"prettyprint" style=3D"background-color=
: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-wrap: brea=
k-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">template</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> F</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">typename</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">...</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Is<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">></span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> C<br></span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">public</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0C</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">std</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
tuple</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span style=3D"color: #606;" class=3D"styled-by-prettify">Is</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">&...>,</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> F</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">&&);</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> <br>=C2=A0 =C2=A0</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> call_f</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 <br><br></span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">private</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0</span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> call_f_helper</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">Is</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">&...);</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">private</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>=C2=A0 =C2=A0 std</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">tuple</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify"><</span><span style=3D"color: #606;" class=3D"styled-by-pr=
ettify">Is</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&...></span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> inputs</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0=
=C2=A0 F f</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">template</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> F</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">typename</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">...</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Is<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">></span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> C</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">F</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">Is</span><span style=3D"color: #660;" class=3D"styled-by-prettify">..=
..>::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">cal=
l_f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">apply</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(&</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify">call_f_helper</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> inputs</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">temp=
late</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> F</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">...</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"sty=
led-by-prettify">Is</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">></span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">aut=
o</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> C</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">F</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" clas=
s=3D"styled-by-prettify">Is</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">...>::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">call_f_helper</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">Is</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&...</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
inputs_unpacked</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">return</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> F</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">inputs_unpacked</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">member_func</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">()...);</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span></div></code></div><div><div><br><br></d=
iv></div><div>But if the member function does take parameters, then assumin=
g we want to pass in the same parameters to all the calls to member_func, t=
here is no way to pass them through with std::apply.</div><div>More general=
ly, given a callable which takes some fixed parameters followed by a parame=
ter pack, there is no way to use std::apply to call the function with the t=
uple mapped into the parameter pack and pass some other arguments into the =
fixed parameters.</div><div><br></div><div>The suggested new overload allow=
s modifying the example to work with member functions that take parameters:=
<br></div><div><br></div><div class=3D"prettyprint" style=3D"background-col=
or: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-wrap: br=
eak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span =
style=3D"color: #008;" class=3D"styled-by-prettify">template</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> F</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">typename</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">...</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Is=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">></span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> C</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">F</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">Is</span><span style=3D"color: #660;" class=3D"styled-by-prettify">..=
..>::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">cal=
l_f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> arg1</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">double</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> arg2</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">return</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">apply</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(&</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">call_f_helper</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> inputs</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> arg1</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> arg2</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br=
></span><span style=3D"color: #008;" class=3D"styled-by-prettify">template<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> F</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">typename</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-b=
y-prettify">Is</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">></span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> C</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">F</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"=
styled-by-prettify">Is</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">...>::</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">call_f_helper</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a=
rg1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">double</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> arg2</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Is</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&...</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> inputs_unpacked</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">return</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
F</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">inputs_unpacked</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">member_func</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">arg1</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> arg2</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">)...);</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">}</span></div></code></div><div><br></div><div>Other alte=
rnatives that could work, and wouldn't require a new overload for std::=
apply:</div></div></div><div>- Concatenating the fixed arguments the beginn=
ing of the inputs tuple, and calling std::apply on that tuple.</div><div>- =
Mapping the inputs tuple to a new tuple of tuples, each tuple containing an=
input an its fixed arguments, and calling std::apply on that.</div><div><b=
r></div><div>Still, I was curious whether the new overload of std::tuple wo=
uld be interesting enough to warrant its (or something similar's) addit=
ion to the standard.</div><div><br></div><div>Thanks,</div><div>Dan</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/5be671fa-c36e-4aed-9409-c7342de0d3b4%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/5be671fa-c36e-4aed-9409-c7342de0d3b4=
%40isocpp.org</a>.<br />
------=_Part_20762_740846800.1514368201894--
------=_Part_20761_2145630912.1514368201892--
.
Author: mihailnajdenov@gmail.com
Date: Wed, 27 Dec 2017 04:17:38 -0800 (PST)
Raw View
------=_Part_20911_1207968446.1514377058806
Content-Type: multipart/alternative;
boundary="----=_Part_20912_2031040568.1514377058807"
------=_Part_20912_2031040568.1514377058807
Content-Type: text/plain; charset="UTF-8"
But isn't using apply a bit of abuse in the first place. Apply is very
simple - you have a callable and arguments pack ant it just calls the
callable with that pack. Very simple to define, explain and use.
You are a bit abusing it by introducing an intermediate mutating callable
and suddenly this callable can't fit into apply interface as it introduces
additional requirements.
Even if extra params are introduced, how will be documented and explained?
And when will be enough?
What if I want inputs_unpacked.member_func(arg1, arg2, std::tuple(argA,
argB)) or inputs_unpacked.member_func(arg1, arg2).member_func2(argA, argB)
)
Anyways, you just need to use index_sequence and invoke directly;
template<typename F, typename... Is>
struct C
{
auto call_f(int arg, int arg2)
{
return variadic_call(arg, arg2, std::index_sequence_for<Is...>{});
}
template <std::size_t... I>
auto variadic_call(int arg, int arg2, std::index_sequence<I...>)
{
return std::invoke(f, std::get<I>(inputs).member_func(arg, arg2)...);
}
std::tuple<Is...> inputs;
F f;
};
This can probably be simplified with some variadic lambda, moving all code
to call_f
--
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/0571ef04-e463-4073-88ca-5d08d60582a3%40isocpp.org.
------=_Part_20912_2031040568.1514377058807
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>But isn't using apply a bit of abuse in the first=
place. Apply is very simple - you have a callable and arguments pack ant i=
t just calls the callable with that pack. Very simple to define, explain an=
d use.</div><div>You are a bit abusing it by introducing an intermediate mu=
tating callable and suddenly this callable can't fit into apply interfa=
ce as it introduces additional requirements.</div><div><br></div><div>Even =
if extra params are introduced, how will be documented and explained? And w=
hen will be enough? </div><div>What if I want <span style=3D"background-col=
or: transparent; border-bottom-color: rgb(0, 0, 0); border-bottom-style: no=
ne; border-bottom-width: 0px; border-image-outset: 0; border-image-repeat: =
stretch; border-image-slice: 100%; border-image-source: none; border-image-=
width: 1; border-left-color: rgb(0, 0, 0); border-left-style: none; border-=
left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none=
; border-right-width: 0px; border-top-color: rgb(0, 0, 0); border-top-style=
: none; border-top-width: 0px; color: rgb(0, 0, 0); font-family: &quot;=
Arial&quot;,&quot;Helvetica&quot;,sans-serif; font-size: 13px; =
font-style: normal; font-variant: normal; font-weight: 400; letter-spacing:=
normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-to=
p: 0px; orphans: 2; padding-bottom: 0px; padding-left: 0px; padding-right: =
0px; padding-top: 0px; text-align: left; text-decoration: none; text-indent=
: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: n=
ormal; word-spacing: 0px;">inputs_unpacked</span><span style=3D"background-=
color: transparent; border-bottom-color: rgb(102, 102, 0); border-bottom-st=
yle: none; border-bottom-width: 0px; border-image-outset: 0; border-image-r=
epeat: stretch; border-image-slice: 100%; border-image-source: none; border=
-image-width: 1; border-left-color: rgb(102, 102, 0); border-left-style: no=
ne; border-left-width: 0px; border-right-color: rgb(102, 102, 0); border-ri=
ght-style: none; border-right-width: 0px; border-top-color: rgb(102, 102, 0=
); border-top-style: none; border-top-width: 0px; color: rgb(102, 102, 0); =
font-family: &quot;Arial&quot;,&quot;Helvetica&quot;,sans-s=
erif; font-size: 13px; font-style: normal; font-variant: normal; font-weigh=
t: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margi=
n-right: 0px; margin-top: 0px; orphans: 2; padding-bottom: 0px; padding-lef=
t: 0px; padding-right: 0px; padding-top: 0px; text-align: left; text-decora=
tion: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-wid=
th: 0px; white-space: normal; word-spacing: 0px;">.</span><span style=3D"ba=
ckground-color: transparent; border-bottom-color: rgb(0, 0, 0); border-bott=
om-style: none; border-bottom-width: 0px; border-image-outset: 0; border-im=
age-repeat: stretch; border-image-slice: 100%; border-image-source: none; b=
order-image-width: 1; border-left-color: rgb(0, 0, 0); border-left-style: n=
one; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right=
-style: none; border-right-width: 0px; border-top-color: rgb(0, 0, 0); bord=
er-top-style: none; border-top-width: 0px; color: rgb(0, 0, 0); font-family=
: &quot;Arial&quot;,&quot;Helvetica&quot;,sans-serif; font-=
size: 13px; font-style: normal; font-variant: normal; font-weight: 400; let=
ter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0p=
x; margin-top: 0px; orphans: 2; padding-bottom: 0px; padding-left: 0px; pad=
ding-right: 0px; padding-top: 0px; text-align: left; text-decoration: none;=
text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; wh=
ite-space: normal; word-spacing: 0px;">member_func</span><span style=3D"bac=
kground-color: transparent; border-bottom-color: rgb(102, 102, 0); border-b=
ottom-style: none; border-bottom-width: 0px; border-image-outset: 0; border=
-image-repeat: stretch; border-image-slice: 100%; border-image-source: none=
; border-image-width: 1; border-left-color: rgb(102, 102, 0); border-left-s=
tyle: none; border-left-width: 0px; border-right-color: rgb(102, 102, 0); b=
order-right-style: none; border-right-width: 0px; border-top-color: rgb(102=
, 102, 0); border-top-style: none; border-top-width: 0px; color: rgb(102, 1=
02, 0); font-family: &quot;Arial&quot;,&quot;Helvetica&quot=
;,sans-serif; font-size: 13px; font-style: normal; font-variant: normal; fo=
nt-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0p=
x; margin-right: 0px; margin-top: 0px; orphans: 2; padding-bottom: 0px; pad=
ding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; tex=
t-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-st=
roke-width: 0px; white-space: normal; word-spacing: 0px;">(</span><span sty=
le=3D"background-color: transparent; border-bottom-color: rgb(0, 0, 0); bor=
der-bottom-style: none; border-bottom-width: 0px; border-image-outset: 0; b=
order-image-repeat: stretch; border-image-slice: 100%; border-image-source:=
none; border-image-width: 1; border-left-color: rgb(0, 0, 0); border-left-=
style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); bord=
er-right-style: none; border-right-width: 0px; border-top-color: rgb(0, 0, =
0); border-top-style: none; border-top-width: 0px; color: rgb(0, 0, 0); fon=
t-family: &quot;Arial&quot;,&quot;Helvetica&quot;,sans-seri=
f; font-size: 13px; font-style: normal; font-variant: normal; font-weight: =
400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-r=
ight: 0px; margin-top: 0px; orphans: 2; padding-bottom: 0px; padding-left: =
0px; padding-right: 0px; padding-top: 0px; text-align: left; text-decoratio=
n: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width:=
0px; white-space: normal; word-spacing: 0px;"><wbr style=3D"border-bottom-=
color: rgb(0, 0, 0); border-bottom-style: none; border-bottom-width: 0px; b=
order-image-outset: 0; border-image-repeat: stretch; border-image-slice: 10=
0%; border-image-source: none; border-image-width: 1; border-left-color: rg=
b(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-c=
olor: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; bord=
er-top-color: rgb(0, 0, 0); border-top-style: none; border-top-width: 0px; =
margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; p=
adding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px=
;">arg1</span><span style=3D"background-color: transparent; border-bottom-c=
olor: rgb(102, 102, 0); border-bottom-style: none; border-bottom-width: 0px=
; border-image-outset: 0; border-image-repeat: stretch; border-image-slice:=
100%; border-image-source: none; border-image-width: 1; border-left-color:=
rgb(102, 102, 0); border-left-style: none; border-left-width: 0px; border-=
right-color: rgb(102, 102, 0); border-right-style: none; border-right-width=
: 0px; border-top-color: rgb(102, 102, 0); border-top-style: none; border-t=
op-width: 0px; color: rgb(102, 102, 0); font-family: &quot;Arial&qu=
ot;,&quot;Helvetica&quot;,sans-serif; font-size: 13px; font-style: =
normal; font-variant: normal; font-weight: 400; letter-spacing: normal; mar=
gin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orph=
ans: 2; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding=
-top: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-=
transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-=
spacing: 0px;">,</span><span style=3D"background-color: transparent; border=
-bottom-color: rgb(0, 0, 0); border-bottom-style: none; border-bottom-width=
: 0px; border-image-outset: 0; border-image-repeat: stretch; border-image-s=
lice: 100%; border-image-source: none; border-image-width: 1; border-left-c=
olor: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border=
-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0=
px; border-top-color: rgb(0, 0, 0); border-top-style: none; border-top-widt=
h: 0px; color: rgb(0, 0, 0); font-family: &quot;Arial&quot;,&qu=
ot;Helvetica&quot;,sans-serif; font-size: 13px; font-style: normal; fon=
t-variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom:=
0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; pad=
ding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; =
text-align: left; text-decoration: none; text-indent: 0px; text-transform: =
none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0p=
x;"> arg2, std::tuple(argA, argB)</span><span style=3D"background-color: tr=
ansparent; border-bottom-color: rgb(102, 102, 0); border-bottom-style: none=
; border-bottom-width: 0px; border-image-outset: 0; border-image-repeat: st=
retch; border-image-slice: 100%; border-image-source: none; border-image-wi=
dth: 1; border-left-color: rgb(102, 102, 0); border-left-style: none; borde=
r-left-width: 0px; border-right-color: rgb(102, 102, 0); border-right-style=
: none; border-right-width: 0px; border-top-color: rgb(102, 102, 0); border=
-top-style: none; border-top-width: 0px; color: rgb(102, 102, 0); font-fami=
ly: &quot;Arial&quot;,&quot;Helvetica&quot;,sans-serif; fon=
t-size: 13px; font-style: normal; font-variant: normal; font-weight: 400; l=
etter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: =
0px; margin-top: 0px; orphans: 2; padding-bottom: 0px; padding-left: 0px; p=
adding-right: 0px; padding-top: 0px; text-align: left; text-decoration: non=
e; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; =
white-space: normal; word-spacing: 0px;">) or=C2=A0<span style=3D"display: =
inline !important; float: none; background-color: transparent; color: rgb(3=
4, 34, 34); font-family: "Arial","Helvetica",sans-serif=
; font-size: 13px; font-style: normal; font-variant: normal; font-weight: 4=
00; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: =
none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0p=
x; white-space: normal; word-spacing: 0px;">=C2=A0</span><span style=3D"bac=
kground-color: transparent; border-bottom-color: rgb(0, 0, 0); border-botto=
m-style: none; border-bottom-width: 0px; border-image-outset: 0; border-ima=
ge-repeat: stretch; border-image-slice: 100%; border-image-source: none; bo=
rder-image-width: 1; border-left-color: rgb(0, 0, 0); border-left-style: no=
ne; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-=
style: none; border-right-width: 0px; border-top-color: rgb(0, 0, 0); borde=
r-top-style: none; border-top-width: 0px; color: rgb(0, 0, 0); font-family:=
&quot;Arial&quot;,&quot;Helvetica&quot;,sans-serif; font-s=
ize: 13px; font-style: normal; font-variant: normal; font-weight: 400; lett=
er-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px=
; margin-top: 0px; orphans: 2; padding-bottom: 0px; padding-left: 0px; padd=
ing-right: 0px; padding-top: 0px; text-align: left; text-decoration: none; =
text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; whi=
te-space: normal; word-spacing: 0px;">inputs_unpacked</span><span style=3D"=
background-color: transparent; border-bottom-color: rgb(102, 102, 0); borde=
r-bottom-style: none; border-bottom-width: 0px; border-image-outset: 0; bor=
der-image-repeat: stretch; border-image-slice: 100%; border-image-source: n=
one; border-image-width: 1; border-left-color: rgb(102, 102, 0); border-lef=
t-style: none; border-left-width: 0px; border-right-color: rgb(102, 102, 0)=
; border-right-style: none; border-right-width: 0px; border-top-color: rgb(=
102, 102, 0); border-top-style: none; border-top-width: 0px; color: rgb(102=
, 102, 0); font-family: &quot;Arial&quot;,&quot;Helvetica&q=
uot;,sans-serif; font-size: 13px; font-style: normal; font-variant: normal;=
font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left:=
0px; margin-right: 0px; margin-top: 0px; orphans: 2; padding-bottom: 0px; =
padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; =
text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text=
-stroke-width: 0px; white-space: normal; word-spacing: 0px;">.</span><span =
style=3D"background-color: transparent; border-bottom-color: rgb(0, 0, 0); =
border-bottom-style: none; border-bottom-width: 0px; border-image-outset: 0=
; border-image-repeat: stretch; border-image-slice: 100%; border-image-sour=
ce: none; border-image-width: 1; border-left-color: rgb(0, 0, 0); border-le=
ft-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); b=
order-right-style: none; border-right-width: 0px; border-top-color: rgb(0, =
0, 0); border-top-style: none; border-top-width: 0px; color: rgb(0, 0, 0); =
font-family: &quot;Arial&quot;,&quot;Helvetica&quot;,sans-s=
erif; font-size: 13px; font-style: normal; font-variant: normal; font-weigh=
t: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margi=
n-right: 0px; margin-top: 0px; orphans: 2; padding-bottom: 0px; padding-lef=
t: 0px; padding-right: 0px; padding-top: 0px; text-align: left; text-decora=
tion: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-wid=
th: 0px; white-space: normal; word-spacing: 0px;">member_func</span><span s=
tyle=3D"background-color: transparent; border-bottom-color: rgb(102, 102, 0=
); border-bottom-style: none; border-bottom-width: 0px; border-image-outset=
: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-s=
ource: none; border-image-width: 1; border-left-color: rgb(102, 102, 0); bo=
rder-left-style: none; border-left-width: 0px; border-right-color: rgb(102,=
102, 0); border-right-style: none; border-right-width: 0px; border-top-col=
or: rgb(102, 102, 0); border-top-style: none; border-top-width: 0px; color:=
rgb(102, 102, 0); font-family: &quot;Arial&quot;,&quot;Helveti=
ca&quot;,sans-serif; font-size: 13px; font-style: normal; font-variant:=
normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; marg=
in-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; padding-botto=
m: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align=
: left; text-decoration: none; text-indent: 0px; text-transform: none; -web=
kit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;">(</spa=
n><span style=3D"background-color: transparent; border-bottom-color: rgb(0,=
0, 0); border-bottom-style: none; border-bottom-width: 0px; border-image-o=
utset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-im=
age-source: none; border-image-width: 1; border-left-color: rgb(0, 0, 0); b=
order-left-style: none; border-left-width: 0px; border-right-color: rgb(0, =
0, 0); border-right-style: none; border-right-width: 0px; border-top-color:=
rgb(0, 0, 0); border-top-style: none; border-top-width: 0px; color: rgb(0,=
0, 0); font-family: &quot;Arial&quot;,&quot;Helvetica&quot=
;,sans-serif; font-size: 13px; font-style: normal; font-variant: normal; fo=
nt-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0p=
x; margin-right: 0px; margin-top: 0px; orphans: 2; padding-bottom: 0px; pad=
ding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; tex=
t-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-st=
roke-width: 0px; white-space: normal; word-spacing: 0px;"><wbr style=3D"bor=
der-bottom-color: rgb(0, 0, 0); border-bottom-style: none; border-bottom-wi=
dth: 0px; border-image-outset: 0; border-image-repeat: stretch; border-imag=
e-slice: 100%; border-image-source: none; border-image-width: 1; border-lef=
t-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; bor=
der-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width=
: 0px; border-top-color: rgb(0, 0, 0); border-top-style: none; border-top-w=
idth: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-=
top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; paddi=
ng-top: 0px;">arg1</span><span style=3D"background-color: transparent; bord=
er-bottom-color: rgb(102, 102, 0); border-bottom-style: none; border-bottom=
-width: 0px; border-image-outset: 0; border-image-repeat: stretch; border-i=
mage-slice: 100%; border-image-source: none; border-image-width: 1; border-=
left-color: rgb(102, 102, 0); border-left-style: none; border-left-width: 0=
px; border-right-color: rgb(102, 102, 0); border-right-style: none; border-=
right-width: 0px; border-top-color: rgb(102, 102, 0); border-top-style: non=
e; border-top-width: 0px; color: rgb(102, 102, 0); font-family: &quot;A=
rial&quot;,&quot;Helvetica&quot;,sans-serif; font-size: 13px; f=
ont-style: normal; font-variant: normal; font-weight: 400; letter-spacing: =
normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top=
: 0px; orphans: 2; padding-bottom: 0px; padding-left: 0px; padding-right: 0=
px; padding-top: 0px; text-align: left; text-decoration: none; text-indent:=
0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: no=
rmal; word-spacing: 0px;">,</span><span style=3D"background-color: transpar=
ent; border-bottom-color: rgb(0, 0, 0); border-bottom-style: none; border-b=
ottom-width: 0px; border-image-outset: 0; border-image-repeat: stretch; bor=
der-image-slice: 100%; border-image-source: none; border-image-width: 1; bo=
rder-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: =
0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-rig=
ht-width: 0px; border-top-color: rgb(0, 0, 0); border-top-style: none; bord=
er-top-width: 0px; color: rgb(0, 0, 0); font-family: &quot;Arial&qu=
ot;,&quot;Helvetica&quot;,sans-serif; font-size: 13px; font-style: =
normal; font-variant: normal; font-weight: 400; letter-spacing: normal; mar=
gin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orph=
ans: 2; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding=
-top: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-=
transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-=
spacing: 0px;"> arg2).<span style=3D"background-color: transparent; border-=
bottom-color: rgb(102, 102, 0); border-bottom-style: none; border-bottom-wi=
dth: 0px; border-image-outset: 0; border-image-repeat: stretch; border-imag=
e-slice: 100%; border-image-source: none; border-image-width: 1; border-lef=
t-color: rgb(102, 102, 0); border-left-style: none; border-left-width: 0px;=
border-right-color: rgb(102, 102, 0); border-right-style: none; border-rig=
ht-width: 0px; border-top-color: rgb(102, 102, 0); border-top-style: none; =
border-top-width: 0px; color: rgb(102, 102, 0); font-family: &quot;Aria=
l&quot;,&quot;Helvetica&quot;,sans-serif; font-size: 13px; font=
-style: normal; font-variant: normal; font-weight: 400; letter-spacing: nor=
mal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0=
px; orphans: 2; padding-bottom: 0px; padding-left: 0px; padding-right: 0px;=
padding-top: 0px; text-align: left; text-decoration: none; text-indent: 0p=
x; text-transform: none; -webkit-text-stroke-width: 0px; white-space: norma=
l; word-spacing: 0px;"></span><span style=3D"background-color: transparent;=
border-bottom-color: rgb(0, 0, 0); border-bottom-style: none; border-botto=
m-width: 0px; border-image-outset: 0; border-image-repeat: stretch; border-=
image-slice: 100%; border-image-source: none; border-image-width: 1; border=
-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px;=
border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-w=
idth: 0px; border-top-color: rgb(0, 0, 0); border-top-style: none; border-t=
op-width: 0px; color: rgb(0, 0, 0); font-family: &quot;Arial&quot;,=
&quot;Helvetica&quot;,sans-serif; font-size: 13px; font-style: norm=
al; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-=
bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans:=
2; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top=
: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-tran=
sform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spac=
ing: 0px;">member_</span>func2(argA, argB)</span><span style=3D"background-=
color: transparent; border-bottom-color: rgb(102, 102, 0); border-bottom-st=
yle: none; border-bottom-width: 0px; border-image-outset: 0; border-image-r=
epeat: stretch; border-image-slice: 100%; border-image-source: none; border=
-image-width: 1; border-left-color: rgb(102, 102, 0); border-left-style: no=
ne; border-left-width: 0px; border-right-color: rgb(102, 102, 0); border-ri=
ght-style: none; border-right-width: 0px; border-top-color: rgb(102, 102, 0=
); border-top-style: none; border-top-width: 0px; color: rgb(102, 102, 0); =
font-family: &quot;Arial&quot;,&quot;Helvetica&quot;,sans-s=
erif; font-size: 13px; font-style: normal; font-variant: normal; font-weigh=
t: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margi=
n-right: 0px; margin-top: 0px; orphans: 2; padding-bottom: 0px; padding-lef=
t: 0px; padding-right: 0px; padding-top: 0px; text-align: left; text-decora=
tion: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-wid=
th: 0px; white-space: normal; word-spacing: 0px;">)=C2=A0</span></span></di=
v><div><br></div><div><br></div><div>Anyways, you just need to use index_se=
quence and invoke directly;</div><div><br></div><div><div class=3D"prettypr=
int" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; =
background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div cla=
ss=3D"subprettyprint"><font color=3D"#004000" face=3D"Arial" style=3D"backg=
round-color: transparent;">template<typename F, typename... Is><br>st=
ruct C<br>{<br>=C2=A0=C2=A0 auto call_f(int arg, int arg2)<br>=C2=A0=C2=A0 =
{<br>=C2=A0=C2=A0=C2=A0=C2=A0 return variadic_call(arg, arg2, std::index_se=
quence_for<Is...>{});<br>=C2=A0=C2=A0 }<br><br></font></div><div clas=
s=3D"subprettyprint"><font color=3D"#004000" face=3D"Arial" style=3D"backgr=
ound-color: transparent;">=C2=A0=C2=A0=C2=A0 template <std::size_t... I&=
gt;<br>=C2=A0=C2=A0=C2=A0 auto variadic_call(int arg, int arg2, std::index_=
sequence<I...>)<br>=C2=A0=C2=A0=C2=A0 {<br>=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 return std::invoke(f, std::get<I>(inputs).member_func(arg, arg=
2)...);<br>=C2=A0=C2=A0=C2=A0 }<br><br></font></div><div class=3D"subpretty=
print"><font color=3D"#004000" face=3D"Arial" style=3D"background-color: tr=
ansparent;">=C2=A0=C2=A0=C2=A0 std::tuple<Is...> inputs;<br>=C2=A0=C2=
=A0=C2=A0 F f;<br>};</font></div><div class=3D"subprettyprint"><font color=
=3D"#004000" face=3D"Arial" style=3D"background-color: transparent;"><br></=
font></div></code></div></div><div><span style=3D"background-color: transpa=
rent; border-bottom-color: rgb(102, 102, 0); border-bottom-style: none; bor=
der-bottom-width: 0px; border-image-outset: 0; border-image-repeat: stretch=
; border-image-slice: 100%; border-image-source: none; border-image-width: =
1; border-left-color: rgb(102, 102, 0); border-left-style: none; border-lef=
t-width: 0px; border-right-color: rgb(102, 102, 0); border-right-style: non=
e; border-right-width: 0px; border-top-color: rgb(102, 102, 0); border-top-=
style: none; border-top-width: 0px; color: rgb(102, 102, 0); font-family: &=
amp;quot;Arial&quot;,&quot;Helvetica&quot;,sans-serif; font-siz=
e: 13px; font-style: normal; font-variant: normal; font-weight: 400; letter=
-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; =
margin-top: 0px; orphans: 2; padding-bottom: 0px; padding-left: 0px; paddin=
g-right: 0px; padding-top: 0px; text-align: left; text-decoration: none; te=
xt-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white=
-space: normal; word-spacing: 0px;"><span style=3D"background-color: transp=
arent; border-bottom-color: rgb(102, 102, 0); border-bottom-style: none; bo=
rder-bottom-width: 0px; border-image-outset: 0; border-image-repeat: stretc=
h; border-image-slice: 100%; border-image-source: none; border-image-width:=
1; border-left-color: rgb(102, 102, 0); border-left-style: none; border-le=
ft-width: 0px; border-right-color: rgb(102, 102, 0); border-right-style: no=
ne; border-right-width: 0px; border-top-color: rgb(102, 102, 0); border-top=
-style: none; border-top-width: 0px; color: rgb(102, 102, 0); font-family: =
&quot;Arial&quot;,&quot;Helvetica&quot;,sans-serif; font-si=
ze: 13px; font-style: normal; font-variant: normal; font-weight: 400; lette=
r-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;=
margin-top: 0px; orphans: 2; padding-bottom: 0px; padding-left: 0px; paddi=
ng-right: 0px; padding-top: 0px; text-align: left; text-decoration: none; t=
ext-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; whit=
e-space: normal; word-spacing: 0px;"><br></span></span></div>This can proba=
bly be simplified with some variadic lambda, moving all code to call_f<div>=
<br></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/0571ef04-e463-4073-88ca-5d08d60582a3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0571ef04-e463-4073-88ca-5d08d60582a3=
%40isocpp.org</a>.<br />
------=_Part_20912_2031040568.1514377058807--
------=_Part_20911_1207968446.1514377058806--
.
Author: dan@soundradix.com
Date: Sun, 31 Dec 2017 07:00:55 -0800 (PST)
Raw View
------=_Part_32366_751464891.1514732455952
Content-Type: multipart/alternative;
boundary="----=_Part_32367_409877343.1514732455953"
------=_Part_32367_409877343.1514732455953
Content-Type: text/plain; charset="UTF-8"
Makes sense.
Although, I really dislike having to us std::index_sequence in my own code
for the purpose of unpacking. I don't mind as long as it's an
implementation detail in library utilities, but I really wish it wouldn't
be required for something as simple as unpacking a variadic tuple in my own
code, because I feel std::index_sequence is logically low-level and I am
forced to use it in my logically-higher-level code, as in this example.
Thanks for the feedback!
Dan
On Wednesday, December 27, 2017 at 2:17:38 PM UTC+2, mihailn...@gmail.com
wrote:
>
> But isn't using apply a bit of abuse in the first place. Apply is very
> simple - you have a callable and arguments pack ant it just calls the
> callable with that pack. Very simple to define, explain and use.
> You are a bit abusing it by introducing an intermediate mutating callable
> and suddenly this callable can't fit into apply interface as it introduces
> additional requirements.
>
> Even if extra params are introduced, how will be documented and explained?
> And when will be enough?
> What if I want inputs_unpacked.member_func(arg1, arg2, std::tuple(argA,
> argB)) or inputs_unpacked.member_func(arg1, arg2).member_func2(argA,
> argB))
>
>
> Anyways, you just need to use index_sequence and invoke directly;
>
> template<typename F, typename... Is>
> struct C
> {
> auto call_f(int arg, int arg2)
> {
> return variadic_call(arg, arg2, std::index_sequence_for<Is...>{});
> }
>
> template <std::size_t... I>
> auto variadic_call(int arg, int arg2, std::index_sequence<I...>)
> {
> return std::invoke(f, std::get<I>(inputs).member_func(arg, arg2)...);
> }
>
> std::tuple<Is...> inputs;
> F f;
> };
>
>
> This can probably be simplified with some variadic lambda, moving all code
> to call_f
>
>
--
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/40261da1-7965-4447-9dd5-5cf8e62f0ae0%40isocpp.org.
------=_Part_32367_409877343.1514732455953
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Makes sense.<div><br></div><div>Although, I really dislike=
having to us =C2=A0std::index_sequence in my own code for the purpose of u=
npacking. I don't mind as long as it's an implementation detail in =
library utilities, but I really wish it wouldn't be required for someth=
ing as simple as unpacking a variadic tuple in my own code, because I feel =
std::index_sequence is logically low-level and I am forced to use it in my =
logically-higher-level code, as in this example.</div><div><br></div><div>T=
hanks for the feedback!</div><div>Dan<br><br>On Wednesday, December 27, 201=
7 at 2:17:38 PM UTC+2, mihailn...@gmail.com wrote:<blockquote class=3D"gmai=
l_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;=
padding-left: 1ex;"><div dir=3D"ltr"><div>But isn't using apply a bit o=
f abuse in the first place. Apply is very simple - you have a callable and =
arguments pack ant it just calls the callable with that pack. Very simple t=
o define, explain and use.</div><div>You are a bit abusing it by introducin=
g an intermediate mutating callable and suddenly this callable can't fi=
t into apply interface as it introduces additional requirements.</div><div>=
<br></div><div>Even if extra params are introduced, how will be documented =
and explained? And when will be enough? </div><div>What if I want <span>inp=
uts_unpacked</span><span>.</span><span>member_func</span><span>(</span><spa=
n>ar<wbr>g1</span><span>,</span><span> arg2, std::tuple(argA, argB)</span><=
span>) or=C2=A0<span style=3D"display:inline!important;float:none;backgroun=
d-color:transparent;color:rgb(34,34,34);font-family:"Arial","=
;Helvetica",sans-serif;font-size:13px;font-style:normal;font-variant:n=
ormal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration=
:none;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0=
px">=C2=A0</span><span>inputs_unpacked</span><span>.</span><span>member_<wb=
r>func</span><span>(</span><span>arg1</span><span>,</span><span> arg2).<spa=
n></span><span>member_</span>func2(argA, argB)</span><span>)=C2=A0</span></=
span></div><div><br></div><div><br></div><div>Anyways, you just need to use=
index_sequence and invoke directly;</div><div><br></div><div><div style=3D=
"border:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rg=
b(250,250,250)"><code><div><font color=3D"#004000" face=3D"Arial" style=3D"=
background-color:transparent">template<typename F, typename... Is><br=
>struct C<br>{<br>=C2=A0=C2=A0 auto call_f(int arg, int arg2)<br>=C2=A0=C2=
=A0 {<br>=C2=A0=C2=A0=C2=A0=C2=A0 return variadic_call(arg, arg2, std::inde=
x_sequence_for<Is...><wbr>{});<br>=C2=A0=C2=A0 }<br><br></font></div>=
<div><font color=3D"#004000" face=3D"Arial" style=3D"background-color:trans=
parent">=C2=A0=C2=A0=C2=A0 template <std::size_t... I><br>=C2=A0=C2=
=A0=C2=A0 auto variadic_call(int arg, int arg2, std::index_sequence<I...=
>)<br>=C2=A0=C2=A0=C2=A0 {<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return std:=
:invoke(f, std::get<I>(inputs).member_<wbr>func(arg, arg2)...);<br>=
=C2=A0=C2=A0=C2=A0 }<br><br></font></div><div><font color=3D"#004000" face=
=3D"Arial" style=3D"background-color:transparent">=C2=A0=C2=A0=C2=A0 std::t=
uple<Is...> inputs;<br>=C2=A0=C2=A0=C2=A0 F f;<br>};</font></div><div=
><font color=3D"#004000" face=3D"Arial" style=3D"background-color:transpare=
nt"><br></font></div></code></div></div><div><span><span><br></span></span>=
</div>This can probably be simplified with some variadic lambda, moving all=
code to call_f<div><br></div></div></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/40261da1-7965-4447-9dd5-5cf8e62f0ae0%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/40261da1-7965-4447-9dd5-5cf8e62f0ae0=
%40isocpp.org</a>.<br />
------=_Part_32367_409877343.1514732455953--
------=_Part_32366_751464891.1514732455952--
.
Author: mihailnajdenov@gmail.com
Date: Mon, 1 Jan 2018 03:38:46 -0800 (PST)
Raw View
------=_Part_34944_752321598.1514806726870
Content-Type: multipart/alternative;
boundary="----=_Part_34945_1998214531.1514806726870"
------=_Part_34945_1998214531.1514806726870
Content-Type: text/plain; charset="UTF-8"
On Sunday, December 31, 2017 at 5:00:56 PM UTC+2, d...@soundradix.com wrote:
>
> Makes sense.
>
> Although, I really dislike having to us std::index_sequence in my own
> code for the purpose of unpacking. I don't mind as long as it's an
> implementation detail in library utilities, but I really wish it wouldn't
> be required for something as simple as unpacking a variadic tuple in my own
> code, because I feel std::index_sequence is logically low-level and I am
> forced to use it in my logically-higher-level code, as in this example.
>
>
Agreed, index_sequence was just a quick fix. Already there are proposals
to be able to simply expand a tuple, like it is a pack.
auto call_f(int arg, int arg2)
{
return std::invoke(f, inputs.member_func(arg, arg2)...);
}
See [RFC] Generalized Unpacking and Parameter Pack Slicing
<https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/PpoY5H6cUAs>
--
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/939eec07-2abe-49c2-b3fb-d26a90611b07%40isocpp.org.
------=_Part_34945_1998214531.1514806726870
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Sunday, December 31, 2017 at 5:00:56 PM UTC+2, =
d...@soundradix.com 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"ltr">Makes sense.<div><br></div><div>Although, I really dislike hav=
ing to us =C2=A0std::index_sequence in my own code for the purpose of unpac=
king. I don't mind as long as it's an implementation detail in libr=
ary utilities, but I really wish it wouldn't be required for something =
as simple as unpacking a variadic tuple in my own code, because I feel std:=
:index_sequence is logically low-level and I am forced to use it in my logi=
cally-higher-level code, as in this example.</div><div><br></div></div></bl=
ockquote><div><br></div><div>Agreed, <span style=3D"display: inline !import=
ant; float: none; background-color: transparent; color: rgb(34, 34, 34); fo=
nt-family: "Arial","Helvetica",sans-serif; font-size: 1=
3px; font-style: normal; font-variant: normal; font-weight: 400; letter-spa=
cing: normal; orphans: 2; text-align: left; text-decoration: none; text-ind=
ent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space=
: normal; word-spacing: 0px;"><font face=3D"courier new,monospace">index_se=
quence</font> </span>was just a quick fix.=C2=A0 Already there are proposal=
s to be able to simply expand a tuple, like it is a pack.</div><div><br></d=
iv><div><br><font face=3D"courier new,monospace"> auto call_f(int arg, in=
t arg2)<br> {<br>=C2=A0 return <span style=3D"text-align: left; color: rg=
b(34, 34, 34); text-transform: none; text-indent: 0px; letter-spacing: norm=
al; font-size: 13px; font-style: normal; font-variant: normal; font-weight:=
400; text-decoration: none; word-spacing: 0px; display: inline !important;=
white-space: normal; orphans: 2; float: none; -webkit-text-stroke-width: 0=
px; background-color: transparent;">std::invoke(f, inputs.member_func(arg, =
arg2)...);</span><br> }</font></div><div><font face=3D"courier new"><br><=
/font></div><div><font face=3D"courier new">See=C2=A0<a href=3D"https://gro=
ups.google.com/a/isocpp.org/forum/#!topic/std-proposals/PpoY5H6cUAs">[RFC] =
Generalized Unpacking and Parameter Pack Slicing </a></font></div><div><br>=
</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/939eec07-2abe-49c2-b3fb-d26a90611b07%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/939eec07-2abe-49c2-b3fb-d26a90611b07=
%40isocpp.org</a>.<br />
------=_Part_34945_1998214531.1514806726870--
------=_Part_34944_752321598.1514806726870--
.