在以下代码段中:
std::string test_path_string_operator_plus_right_xref(path_string && right_path_str)
{
return "aaa" + right_path_str;
}
right_path_str
当模板重载不可用时,它将绑定到
friend path_basic_string operator+ (const t_elem * p, const base_type & r)
当模板存在时,它更适合于非常量左值引用:
template <typename T>
friend path_basic_string operator+ (const t_elem * p, T && r)
在这种情况下,
T&&
是一个转发引用,它折叠为非常量左值引用。要修复代码,请确保
move
std::move
std::forward
std::string test_path_string_operator_plus_right_xref(path_string && right_path_str)
{
return "aaa" + std::move(right_path_str);
}