This is a follow-up to my previous question: C++ - Constructing wrapper class with same syntax as wrapped data
Basically, I'm trying to make a wrapper template around some data, and construct / set the wrapper with the same syntax as the data.
If I use something like a struct, I can achieve that with forwarding the parameters so the syntax can be:
struct SomeStruct{
int a, b, c;
SomeStruct(int _a, int _b, int _c) {/*...*/}
};
// ...
WrapperClass<SomeStruct> wrapped_struct1{1,2,3};
WrapperClass<SomeStruct> wrapped_struct2 = {1,2,3};
WrapperClass<SomeStruct> wrapped_struct3( 1,2,3);
The problem is that this only works if I have that constructor defined in the struct. Can I make it work without having to define it?
The wrapper currently looks like this:
template<typename T> class WrapperClass{
public:
T data;
template <typename...Args>
WrapperClass(Args&&...args) : data(std::forward<Args>(args)...) {}
};