preparing下一个C ++标准 [英] Preparing for the next C++ standard

查看:129
本文介绍了preparing下一个C ++标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于 BOOST_FOREACH 问题接二连三提示我问Boost库的用户是什么(如果有的话),他们在做prepare其code代表便携性提出了新的C ++标准(又名的C ++ 0x)。例如,你写code这样如果你使用的shared_ptr

The spate of questions regarding BOOST_FOREACH prompts me to ask users of the Boost library what (if anything) they are doing to prepare their code for portability to the proposed new C++ standard (aka C++0x). For example, do you write code like this if you use shared_ptr:

#ifdef CPPOX
#include <memory>
#else
#include "boost/shared_ptr.hpp"
#endif

还有命名空间问题 - 在未来,的shared_ptr 将是 STD ,命名空间的一部分 - 你如何与应对?

There is also the namespace issue - in the future, shared_ptr will be part of the std, namespace - how do you deal with that?

我感兴趣的是这些问题,因为我已经决定硬着头皮开始学习提升认真,我想在我的code使用的最佳实践。

I'm interested in these questions because I've decided to bite the bullet and start learning boost seriously, and I'd like to use best practices in my code.

不完全是一个答案洪水 - 这意味着它是一个非问题?无论如何,感谢那些回答;我接受jalfs答案,因为我被建议喜欢做什么!

推荐答案

简单的答案是什么都不做。升压不会删除得到了采纳到0X库。因此,提高:: shared_ptr的仍然存在。所以,你不需要做任何事情,以保持便携性。

The simple answer is "do nothing". Boost is not going to remove the libraries that got adopted into 0x. So boost::shared_ptr will still exist. So you don't need to do anything to maintain portability.

当然,一旦0X在这里,有很多code可以简化,清理和优化,但因为它是尚未在这里,这项工作不能真正开始。所有你能做的就是确保当输入0x打你的code仍将编译......这应该就是这样。升压是不会删除一半的库。 (我不是在猜想,他们已经表示他们这个邮件列表之前)

Of course, once 0x is here, a lot of code can be simplified, cleaned up and optimized, but since it's not yet here, that work can't really begin. All you can do is make sure your code will still compile when 0x hits... and it should, just like that. Boost isn't going to delete half their libraries. (I'm not guessing. They've stated this on their mailing list before)

(如果你想切换到标准的shared_ptr的,我会说这可能更容易只是做一个简单的搜索/到时候更换更换的#include&LT;升压/ shared_ptr的。 HPP&GT; 的#include&LT;内存&GT; 的boost :: shared_ptr的的std :: shared_ptr的

(and if you want to switch to the standard shared_ptr, I'd say it's probably easier to just do a simple search/replace when the time comes. Replace #include <boost/shared_ptr.hpp> with #include <memory>, and boost::shared_ptr with std::shared_ptr)

或者,当然,你可以决定你要去使用Boost的的shared_ptr 来保持项目。只是因为它是被添加到标准库并不意味着你的有无的使用它,毕竟。

Or of course, you can just decide on the project that you're going to keep using Boost's shared_ptr. Just because it's been added to the standard library doesn't mean you have to use it, after all.

这篇关于preparing下一个C ++标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆