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

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 2019-09-18 08:22 -0700
Organization A noiseless patient Spider
Message-ID <86ftkt4ok2.fsf@linuxsc.com> (permalink)
References <pxjbF.468705$tG2.346514@fx48.iad> <yZOcF.103013$9J3.42139@fx11.iad>

Show all headers | 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