1
忽略我所描述的理解的完整性,使用std::move()
函數在用於將參數傳遞給基礎構造函數時會提高構建時間嗎?將參數傳遞給基類時使用std :: move()
struct Bar {
Bar(std::string);
std::string _s;
}
struct Foo : public Bar {
Foo(std::string);
}
struct Bar(std::string bs) : _s(std::move(bs)) {
// 1
}
struct Foo(std::string fs) : Bar(std::move(fs)) {
// 2
}
在這個例子中
是這樣,那麼在的Foo
構造函數中使用的move()
防止串的其他副本正在取得?
而且澄清,這是否意味着設計不應該嘗試使用在點// 1
和// 2
bs
和fs
,但使用_s
會在這兩個地方是安全的?
這是一個很好的實驗;謝謝。 –