无序映射的左值到右值转换

问题描述 投票:1回答:1

从外部库接收参数:

candidate function not viable: no known conversion from 'std::unordered_map<string, string>' to 'std::unordered_map<string, string> &&' (aka 'unordered_map<basic_string<char>, basic_string<char> > &&') for 1st argument

void someMethod(shared_ptr<Context> ctx, std::unordered_map<string, string>&& config) {
    ctx->setConfigOverrides(config);
}

// From Context :
// I can't change following method :
void setConfigOverrides(
    std::unordered_map<string, string>&& configOverrides) {
    setConfigOverrides(make_shared<const MemConfig>(move(configOverrides)));
}
c++ rvalue lvalue
1个回答
0
投票
您错过了将输入参数移至下一个相同的接收器的问题。这个:
© www.soinside.com 2019 - 2024. All rights reserved.