suppose have class this:
class foo { const arr; foo(b arg): arr(arg) { } };
what efficient choice types of a
, b
. thinking this,
class foo { const std::initializer_list<std::string> arr; foo(std::initializer_list<std::string> arg): arr(arg) { } };
but think copy-construct strings in arr
. i'd able this:
std::string str1("there"), str2("now"); foo bar({"hello",str1,std::move(str2)});
and have rvalue strings in brackets moved arr
.
should use std::initializer_list
, or std::vector
, or else?
define arr
std::vector<std::string>
, , ctor's argument std::initializer_list<std::string>
, have guessed.
Comments
Post a Comment