So I want to pass an array of std::strings to a function. The number of std::strings in the array is predefined via preproc. directives. The whole thing should look like this:
#define ARRAYSIZE 3
void foo(std::string[ARRAYSIZE]);
void foo(std::string instrings[ARRAYSIZE])
{
...
}
Question: Can I call on the function without having to save the std::string array first to a variable, and then calling with that? So basically I want to call it with one line, like:
void main()
{
...
foo( std::string x[ARRAYSIZE] = {"abc","def","ghi"} );
...
}
Problem is that I can't figure out the correct syntax of the function call (I'm not even sure there is one), visual studio's intellisense keeps shooting my ideas down.
std::arrayandstd::vectoris good for the soul.#definefor constants is totally unnecessary. Useconstorconstexprinstead.