I have a bunch of questions about random engines and distributions, their cost and interaction:
std::uniform_int_distribution<> distr(1, 10);
auto random_value = distr(gen);
1) Usually it isn't, initialization either is trivial or comaprable to some PRNG initialization, however invoking
operator() might access OS for secure random number and it could be costly.
2) Mostly depends on distribution. They containg distribution parameters (which you can retrieve if you want) and optionally some inner state (IIRC most implementation doesn't bother with it). So initializating distribution is like initializating small structure.
3) Distribution object invokes generators
operator() unspecified amount of times (from 0 to ∞ times) and creates a random number from bit sequence produced by generator. Then it returns generated bumber.
It potentially advances generator state and might store unused bits produced by generator in distribution internal state.
random_device, probably, does not even has internal state, if it implemented as handle to system RNG. Otherwise, its state is advanced on second line, when you invoke its
operator() to produce random number you will use as seed for your generator.