Hello
is there fast way to convert c char** to std::string[] array without loop the char** ?
Hello
is there fast way to convert c char** to std::string[] array without loop the char** ?
Nope.
Well there's probably some cute one-liner statement you could use from the STL, but that would only hide the loop from your code, and it wouldn't make it noticeably any faster.
Why are you trying to optimise something which only happens once anyway?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Salem is right on both accounts. A possible one-liner:
This uses the pointer to c-strings as iterator, which can be used for the vector constructor.Code:std::vector<std::string> strings(cstrings, cstrings + num_cstrings);