Convert GenRandom to use std::function.