小编J. *_*Doe的帖子

调用函数的歧义.隐含转换?

#include <string>

void f(std::string&& rref){
}

void f(std::string s){ 
}

int main() {
    std::string s = "s";
    f(std::move(s));
}
Run Code Online (Sandbox Code Playgroud)

这段代码引起歧义,我不知道为什么,我可能会明确转换为右值引用.

我的想法是rvalue引用可以隐式转换为lvalue.但我不确定.请解释.

c++ overload-resolution move-semantics c++11

8
推荐指数
1
解决办法
173
查看次数

标签 统计

c++ ×1

c++11 ×1

move-semantics ×1

overload-resolution ×1