Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Slightly different syntax but...</p> <pre><code>#include &lt;boost/preprocessor.hpp&gt; #include &lt;iostream&gt; void f1(int x, int y, char* z) { std::cout &lt;&lt; "::f1(int,int,char*)\n"; } #define GENERATE_ARG(z,n,unused) BOOST_PP_CAT(arg,n) #define GET_ARGS(n) BOOST_PP_ENUM(n, GENERATE_ARG, ~) #define GENERATE_PARAM(z,n,seq) BOOST_PP_SEQ_ELEM(n,seq) GENERATE_ARG(z,n,~) #define GENERATE_PARAMS(seq) BOOST_PP_ENUM( BOOST_PP_SEQ_SIZE(seq), GENERATE_PARAM, seq ) #define PASSTHROUGH(Classname, Function, ArgTypeSeq) \ void Classname::Function( GENERATE_PARAMS(ArgTypeSeq) ) \ { \ ::Function( GET_ARGS( BOOST_PP_SEQ_SIZE(ArgTypeSeq) ) ); \ } struct test { void f1(int,int,char*); }; PASSTHROUGH(test,f1,(int)(int)(char*)) int main() { test().f1(5,5,0); std::cin.get(); } </code></pre> <p>You could get something closer to yours if you use tuples, but you'd have to supply the arg count to the base function (you can't derive a size from a tuple). Sort of like so:</p> <pre><code>PASSTHROUGH(test,f1,3,(int,int,char*)) </code></pre> <p>That about what you're looking for? I knew it could be done; took about a half hour to solve. You seem to expect that there's an implicit 'this' that has to be gotten rid of but I don't see why...so maybe I misunderstand the problem. At any rate, this will let you quickly make default "passthrough" member functions that defer to some global function. You'll need a DECPASSTHROUGH for the class declaration if you want to skip having to declare them all...or you could modify this to make inline functions.</p> <p>Hint: Use BOOST_PP_STRINGIZE((XX)) to test the output of preprocessor metafunctions.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload