why main?
#include <initializer_list>
#include <vector>
#include <string>
std::vector<std::string> stringSplit(std::string s1, std::string s2){return {};}
int main(void) {
typedef struct {
std::string var, val;
std::vector<std::string> splitVals;
std::vector<std::string> splitValsDuplicates;
} S;
std::vector<S> vsVars={
"PATH", getenv("PATH"),
stringSplit(getenv("PATH"),
":"),
{}//empty vector of string, right? it doesn't pass.
};//this is the default, PATH variable, for no parameters
return 0;
}
/*
unit-test-initializer-list-bug.cpp: In function 'int main()':
unit-test-initializer-list-bug.cpp:16:2: error: could not convert '{"PATH", getenv(((const char*)"PATH")), stringSplit(std::__cxx11::string, std::__cx
x11::string)(std::__cxx11::basic_string<char>(((const char*)":"), std::allocator<char>())), <brace-enclosed initializer list>()}' from '<brace-enclose
d initializer list>' to 'std::vector<main()::S>'
};//this is the default, PATH variable, for no parameters
^
Fri 03/03/2017 10:38:29.87|L:\projects\prpath\1.5\win\tests||>g++ -static -std=c++14 -lstdc++ -o unit-test-initializer-list-bug.exe unit-test-ini
tializer-list-bug.cpp
*/
6.2.0 sjlj
revised source
solution was to put the struct portion in curly braces inside the vector braces, wasn't thinking clearly enough, and compiler was throwing a strange error. now compiles.
corrected src