How to code a generic/templated proxy class P to have the same constructor signature of some represented classes C, and forward those arguments from P to C unaltered, without any runtime overhead?
(Because P is generic, C constructor may have any number and types of arguments, even none).
Example code:
class C {
public:
C(int i, string s, bool b,... /* assorted number and types of arguments, maybe none */) {
/* ... */
}
/* other methods */
};
template<typename T>
class P {
public:
P(/* same arguments of T constructor */) {
// get a T instance
T t(/* forward arguments from P constructor, unaltered */);
/* ... */
}
/* other methods */
};
Using P:
P<C> p{/* arguments required by C */};
p.some_p_method();