Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是UB做以下事情吗?
void foo(std::string_view view) {...} void bar() { std::string str; foo(std::move(str)); }
谢谢!
这是定义明确的行为,尽管它不是特别有用。basic_string'soperator basic_string_view将用于执行转换,它没有左值/右值限制。因此,如果您根本不使用它,它会做同样的事情move。
basic_string
operator basic_string_view
move