c++11 - c++ custom container pass {} list -
i remaking set container , wondering how pass brace-enclosed initializer list container.
myset<int> myset = {"test", "test 2"};
i tried overload operator= take list parameter.
despite presence of =
here, constructing set, need constructor (that takes std::initializer_list
parameter).
template<class t> class myset { public: // ... myset(std::initializer_list<t> init) { (t const &t : init) insert(t); } };
Comments
Post a Comment