这是一个跟进问题: std :: initializer_list as std :: array constructor
我从那里得到的答案中学到了一点退出并尝试扩展我的包装类.简而言之,这个问题,我的解决方案以及它的问题.
问题:我需要一个从模板创建数组的类,没有默认构造函数和未知数量的参数.它本身可以使用可变参数模板包装在其他类中.
我的解决方案:工作但不是真正的用户友好因此我希望有一些想法来改进它 运行示例
class a // some sort of storage class that need wrapper for more functions
{
public:
a(int c)
{
std::cout << "Class A: " << c << std::endl;
}
};
template<class TStack>
class b : public TStack // wrapper with char input
{
public:
template<class ... TArgs>
b(char c, TArgs&& ... args)
: TStack( std::forward<TArgs>(args)...)
{
std::cout << "Class B: " << c << std::endl; …Run Code Online (Sandbox Code Playgroud)