Why not simply write the following?
const Config config { loadConfig() };
for (auto &name : config.names) {
use(name);
}
Or else you could have "loadConfig()" be a method that returns a reference, which is in turn the member of a class, so that there isn't any dangling reference issue.