Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to generate a member function with a deduced signature
    primarykey
    data
    text
    <p>is it possible to produce method definition (with an exact number of parameters and return value of known type), having:</p> <ul> <li>method argument types "frozen" in a variadic arguments pack</li> <li>deduced method return type</li> <li>method name (passed to a macro?)</li> </ul> <p>Details:</p> <p>I have a simple reflection structure (partial specialisation stuff omited for readability), which deduces member functions return type and argument types:</p> <pre><code>template&lt;typename RetType, typename ...ArgTypes&gt; struct reflect_method&lt;RetType(HostClassType::*)(ArgTypes...)&gt; { using method_type = RetType; using method_args = type_placeholder&lt;ArgTypes...&gt;; using call_type = RetType(HostClassType::*)(ArgTypes...); }; </code></pre> <p>where <code>method_type</code> is a method return type, <code>method_args</code> are a method argument types "frozen" in a helper template struct <code>type_placeholder</code>.</p> <p>What I'm trying to do is to create a method in a generated class which will reflect arguments and return type of another method of some other class. The created method will provide a decoration for the reflected method.</p> <p>Pseudocode implementation:</p> <pre><code>#define RPCCLASS(class_name) class RPC##class_name : public class_name \ { \ using SelfType = RPC##class_name; \ using ParentType = class_name; #define RPCCLASS_END() }; #define RPCBIND(method_name) \ using method_name_##tag = reflect_method&lt;decltype(ParentType::method_name)&gt;; \ method_name_##tag::method_type method_name(method_name_##tag::method_args::at&lt;0&gt;::type arg0, \ method_name_##tag::method_args::at&lt;1&gt;::type arg1, \ /* ... */ \ /*don't know how to put correct number of arguments here)*/) \ { \ /* do some stuff */ \ /* ... */ \ /* invoke the reflected method */ \ return Invoke&lt;method_name_##tag&gt;::apply(this, method_name, \ arg0, \ arg1 \ /*again don't know how to put correct number of arguments here)*/) \ } // USAGE: class MyOwnClass { public: virtual long long doFun(int a, char b, const std::string&amp; c); }; RPCCLASS(MyOwnClass) RPCBIND(doFun) RPCCLASS_END() </code></pre>
    singulars
    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.
 

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