Now I want to write a general template which can instance class, of course, these classes might have none or multiple parameters. So the template must have variadic arguments. Anybody can help me?
To better make myself understood, please see the follwong simple code snippet, I don't know how to make it work:
class Print
{
public:
Print(const char* param, const char* param2)
: m_str1(param)
, m_str2(param2)
{}
void outPut()
{
std::cout << m_str1 << "\t" << m_str2 << std::endl;
}
private:
std::string m_str1;
std::string m_str2;
};
template<typename ... Ts>
struct adapter
{
static void invoke()
{
C t((Ts::value)...); // make a instance on the fly
}
};
update: When I try to write such code, it won't compile:
adapter<const char*, const char*>;