迁移到c ++ 11 [英] migration to c++11

查看:126
本文介绍了迁移到c ++ 11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用c ++主要用于其核心组件的产品。虽然它使用视觉c ++作为Windows平台的主要编译器,它的编辑器和调试器作为主要的开发环境,不使用任何Microsoft特定的技术。对于其他平台,它使用gcc进行编译。

I am working for a product which uses c++ primarily for it's core components. Though it uses visual c++ as primary compiler for windows platform and it's editor and debugger as primary developing environment, is not using any Microsoft specific technologies. For other platforms it uses gcc for compilation.

我的代码库大量使用模拟的右值引用(使用boost移动库),可变参数模板表达式模板。

My code base heavily uses emulated rvalue reference (using boost move library), variadic templates (using boost processor) and in some cases expression templates.

我试图切换到c ++ 11,使用rvalue引用,完美转发,默认和删除构造函数,可变参数模板和自动decltype。

I am tempted to switch to c++11 to get a cleaner code base using rvalue reference, perfect forwarding, default and delete for constructors, variadic templates, and auto and decltype.

如果我这样做,我可以做一些修改现有的代码来简化它(使用模板别名,可能是constexpr)。在这种情况下,我必须切换到gcc Windows平台使用mingw,因为visual studio没有实现默认和删除,和可变参数模板。另外,我必须切换到gdb作为调试器和一个不同的代码编辑器。

If I do so, I may do some rework on the existing code to simplify it (using template alias and may be constexpr). In that case I have to switch to gcc for windows platform using mingw, as visual studio has no implementation for default and delete, and variadic template. Also I have to switch to gdb as debugger and a different code editor.

对于我来说,在代码简单性和性能方面看起来巨大,但是稳定性,可用性(在某些平台,如Android),调试(从visual studio迁移到gdb,因为我们有许多可视化工具开发的视觉工作室调试器)和代码编辑器(不是那么多,对于大量的模板代码我没有发现很多使用自动完成,重构等,以及codelite,代码块,qt creator与我们的构建系统)是一些问题。

For me benefit looks huge in terms of code simplicity and performance, however stability, availability (on some platform such as Android) , debugging (migrating from visual studio to gdb, as we have many visualization tools developed for visual studio debugger) and code editor (not so much as for heavily templates code I do not find much uses of auto completion, refactoring etc, and codelite, codeblocks, qt creator works well with our build system) are some of the issues.

我想知道是否有任何商业或开源的中型/大型项目正在使用/打算使用任何以上c ++ 11的功能?

I like to know if any of the medium/large scale project either commercial or open source, are using/intend to use any of the above c++11 features? And how much effort is required to do such migration?

任何实际的经验,技巧或智慧的话都会帮助我作出决定。

Any practical experience, tips or words of wisdom will help me to take a decision.

推荐答案

首先:取决于政策。

工作到新的东西本身就是一种风险。根据你的思维方式和你的项目的危险程度,你接受的风险程度可能不同(例如,我使用树的版本Clang的个人项目,但成熟的gcc在工作)。

Like all technologies, switching from something that works to something new is a risk in itself. Depending on your mindset and the criticity of your project, the degree of risk you accept may differ (for example, I use the top of tree version of Clang for personal projects but a mature gcc at work).

就我个人而言,我建议您不要潜水头潜进行生产准备项目,而是逐步选择有效的功能。

Personally, I would recommend not diving head-first for production ready projects, but instead perform a piecemeal selection of the features that work.

您提到:


  • rvalue references&完美转发

  • 默认 / delete

  • variadic模板

  • 类型推断( auto / decltype

  • 模板别名和 constexpr

  • rvalue references & perfect forwarding
  • default/delete
  • variadic templates
  • type inference (auto/decltype)
  • template aliases and constexpr

VC ++ 11附带了许多C ++ 11功能的支持 。例如,您现在可以立即开始使用右值引用类型推断。如果我记得正确,这已经超过一年了,这么好穿。这些可以使用gcc 4.5.x分支。

VC++11 comes with support for many C++11 features. You could start using rvalue references and type inference right now, for example. And those can be used with gcc 4.5.x branch if I recall correctly, which is already more than a year old, so well worn.

一个值得注意的缺席从你的列表

One notable absence from your list are lambdas for example, which are supported by both VC++11 and gcc too.

如果你想进一步移动,那么你将会必须切换编译器和环境。这个努力是显着更大,因为你将需要重新训练团队(个人我已经有一些疣与gmb on mingw ...)。

If you want to move further, then you will have to switch compiler and environment. The effort is significantly greater as you will need to retrain the team (personally I have had some warts with gdb on mingw...).

我建议樱桃采摘工作在两个编译器,现在,除非你感到冒险。迁移总是一种商业风险。

I would advise cherry picking what works on both compilers, for now, unless you feel adventurous. Migration is always a business risk though.

这篇关于迁移到c ++ 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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