- 402 名前:デフォルトの名無しさん mailto:sage [2009/04/23(木) 00:40:38 ]
- >388
それはshared_ptrのオーナー次第。関数自体はオーナーじゃ無いことに注意する必要がある。 下記はかなり恣意的な例だけど、マルチスレッドプログラムだとすぐ嵌りそうですな。 struct A { A() : s(new std::string) {}; boost::shared_ptr<string> s; } void doom(std::auto_ptr<A> body, boost::shared_ptr<string>& str) { *str; // boo!! }; int main() { std::auto_ptr<A> a(new A); doom(a, a->s); }
|

|