Copying a std::initializer_list
does not copy its underlying objects. It's not meant to be used as a container. What you should be doing instead is storing it in something else, like a std::vector
:
class A
{
public:
A(std::initializer_list<std::string> il) :
m_il(il)
{}
std::vector<std::string> m_il;
};