I have seen several usages of std::mt19937 like following:
#include <random>
size_t get_rand()
{
static thread_local std::mt19937 generator(time(0));
std::uniform_int_distribution<int> distribution(0, 10);
return distribution(generator);
}
I want to find out what benefits comes from using static thread_local rather than static here. // first static is redundant
I understand that in the second case generator has lifetime until thread is finished.
Are there other benefits/differences in common or this particular case?