Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #68500

Re: Problem solved: forward variable number of arguments precisely to a template method

Path csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups comp.lang.c++
Subject Re: Problem solved: forward variable number of arguments precisely to a template method
Date Wed, 18 Sep 2019 08:22:21 -0700
Organization A noiseless patient Spider
Lines 28
Message-ID <86ftkt4ok2.fsf@linuxsc.com> (permalink)
References <pxjbF.468705$tG2.346514@fx48.iad> <yZOcF.103013$9J3.42139@fx11.iad>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Info reader02.eternal-september.org; posting-host="d7421874ff1696044f351dbc5e408957"; logging-data="28854"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/BXuyTHxVD3VfmOIPpcNDzkfYr0FJeUGA="
User-Agent Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock sha1:9Dkd+nnz+Ld4okLPGm5n3rSX/7k= sha1:sdhN6HgemyBdzfmh5uhq7gMjYZ4=
Xref csiph.com comp.lang.c++:68500

Show key headers only | View raw


Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> writes:

> I just realized the problem was solved (not by me but by a high-class
> C++ expert who is a colleague of mine, to my luck).  The below solution
> works with gcc 4.8.5.  The key is to apply "Identity" pattern to the
> variable parameter type list and provide more information for type
> deduction.  [...]
>
> [ and the key part is ]
>
> template<class T>
> struct Identity {
>   using type = T;
> };
>
> template <class T, const int>
> struct Caller {
>   Caller(T& to):  o(to) {}
>   T& o;
>   template<class... A>
>   void callMethod(void (T::*m)(A...), typename Identity<A>::type... args) {
>     (o.*m)(args...);
>   }
> };

Interesting.  It took me a while to figure out what's going on
and why this works.  At first it looked exactly backwards, but
in retrospect it makes sense.  Kudos to your colleague.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

forward variable number of arguments precisely to a template method Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2019-09-02 21:41 -0400
  Re: forward variable number of arguments precisely to a template method Öö Tiib <ootiib@hot.ee> - 2019-09-03 00:24 -0700
    Re: forward variable number of arguments precisely to a template method Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2019-09-04 10:47 -0400
      Re: forward variable number of arguments precisely to a template method Manfred <noname@add.invalid> - 2019-09-05 20:21 +0200
  Re: forward variable number of arguments precisely to a template method Vir Campestris <vir.campestris@invalid.invalid> - 2019-09-03 21:29 +0100
    Re: forward variable number of arguments precisely to a template method Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2019-09-04 11:08 -0400
  Re: forward variable number of arguments precisely to a template method Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-09-06 03:17 -0700
    Re: forward variable number of arguments precisely to a template method Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2019-09-06 23:48 -0400
  Problem solved: forward variable number of arguments precisely to a template method Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2019-09-07 10:16 -0400
    Re: Problem solved: forward variable number of arguments precisely to a template method Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-09-18 08:22 -0700

csiph-web