for (size_t i = r.begin(); i < r.end(); i++)
{
test_prime(i);
}

and the main loop in test_prime needs to be changed to

for (int i = 2; i <= sqrt((double) num); i+=1)
{
if (num % i == 0)
{
is_prime = false;
break;
}
}