Convert std::vector to TArray?

Is there a good way to convert a std::vector to a TArray?

For now I have

for (auto i : permutation_vector)
	result.Add(i);

Instead of iterating over the elements, you could use the fact that vectors store their data consecutively and append the whole vector in one go:

if (!permutation_vector.empty())
{
  result.Append(permutation_vector.data(), permutation_vector.size());
}

data() may return a null pointer if the vector is empty, so the check is necessary unless you’re absolutely sure your vector contains elements.

looks like that’s the best way to do it!