简体   繁体   English

适用于Windows Mobile 6 SDK的智能指针

[英]Smart pointers for Windows Mobile 6 SDK

I cannot get std::tr1::shared_ptr for my WinMobile project since the STL for WinCE is maintained by a different team at Microsoft :( aarrgh... 我不能为我的WinMobile项目获得std :: tr1 :: shared_ptr,因为WinCE的STL由Microsoft的另一个团队维护:( aarrgh ...

Anyone worked with another thread-safe, reference counting smart pointers? 任何人都使用另一个线程安全,引用计数智能指针? I'm actually using yasper which seems to be good. 我实际上正在使用似乎很好的yasper。

Thank you very much. 非常感谢你。

I'd also recommend boost::shared_ptr. 我还建议使用boost :: shared_ptr。 You can do what I did for a library, and use a #define to switch between std::tr1::shared_ptr and boost::shared_ptr, depending on the capabilities of the compiler. 您可以执行我为库所做的操作,并使用#define在std :: tr1 :: shared_ptr和boost :: shared_ptr之间切换,具体取决于编译器的功能。 That way your code doesn't need to be modified [much] if/when the CE team add tr1 support. 这样,如果/当CE团队添加tr1支持时,您的代码不需要被修改[很多]。 Just my 2c. 只是我的2c。

Boost Smart Pointers . 提升智能指针 In particular boost::shared_ptr . 特别是boost :: shared_ptr I am pretty sure they are supported for your platform. 我很确定它们适用于您的平台。 This is where tr1::shared_ptr came from. 这是tr1 :: shared_ptr的来源。

Have you looked at STLPort or the Dinkum TR1 library ? 你看STLPort的鼎信TR1库 Both have a much more complete port for CE. 两者都有一个更完整的CE端口。

yasper::ptr seems to be similar to Boost Smart Pointers, altough shared_ptr of course has more features. yasper :: ptr似乎与Boost Smart Pointers相似,尽管shared_ptr当然有更多功能。

In the scarce yasper::ptr documentation an example of pointer assignment appears: 在稀缺的yasper :: ptr文档中,出现了一个指针赋值示例:

 //preferred  
ptr<SomeClass> p1(new SomeClass);

 //less safe  
ptr<SomeClass> p2 = new SomeClass; 

Why the second from would be 'less safe'? 为什么第二个会“不太安全”?

Yes I'm thinking into using shared_ptr, but Visual C++ 2008 does not have it under std::tr1 for WinCE builds, so may be I look those alternatives, thank you. 是的我正在考虑使用shared_ptr,但是Visual C ++ 2008在WinE版本的std :: tr1下没有它,所以我可能会看看那些替代品,谢谢。 I'm happy with yasper::ptr but I doubt it's thread safe. 我对yasper :: ptr很满意,但我怀疑它是否安全。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM