The following C++ function is extracted from lines 151 - 157 here:
template <typename... T>
std::string JoinPaths(T const&... paths) {
boost::filesystem::path result;
int unpack[]{0, (result = result / boost::filesystem::path(paths), 0)...};
static_cast<void>(unpack);
return result.string();
}
The function JoinPaths("foo", "bar", "doo.txt") will return a std::string with value "foo/bar/doo.txt" (I think) so I understand the semantics of the function.
I am trying to understand the two lines before the return statement. unpack in an array of ints, but what (and why) is happening with the leading 0's and the ellipses at the end. Can someone explain how this gets expanded? Why the 0's? I assume the static_cast is there to keep the compiler from optimizing away the array?