Hello
is there fast way to convert c char** to std::string[] array without loop the char** ?
This is a discussion on convert char** (c string array) to std::string[] within the C++ Programming forums, part of the General Programming Boards category; 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.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
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);