简体   繁体   English

库计划C ++ 0x?

[英]Library plans for C++0x?

Lately I've been getting very excited about the support for lambdas in VC2010. 最近我对VC2010中对lambdas的支持感到非常兴奋。 I'm slowly starting to grasp the full potential this feature has in transforming C++ into something alot better. 我正在慢慢开始把握这个功能在将C ++转化为更好的东西方面的​​全部潜力。

But then I realized that this potential greatly depends on main stream support of lambdas in day to day libraries like boost and QT. 但后来我意识到这种潜力在很大程度上取决于lambdas在日常图书馆中的主流支持,如boost和QT。
Does anyone know if there are plans to extend these libraries with the new features of C++0x? 有谁知道是否有计划使用C ++ 0x的新功能扩展这些库?

lambdas practically replace the need for boost::lambda and everything in boost that interacts with it. lambdas实际上取代了对boost :: lambda的需求以及与之交互的boost中的所有内容。 QT could add support for lambdas in all of their container and maybe even as an alternative way of defining SLOT s QT可以在所有容器中添加对lambdas的支持,甚至可以作为定义SLOT的替代方法

Lambdas already fit very well into existing libraries - anywhere that a function accepts a function object of a type given by a template parameter. Lambdas已经非常适合现有的库 - 函数接受模板参数给出的类型的函数对象的任何地方。

This is one of the great things about them - they're a classic example of a language feature that codifies existing practice in a nifty syntax. 这是关于他们的伟大事情之一 - 他们是一个语言特征的经典例子,它以一种漂亮的语法编纂现有的实践。

Obviously the boost lambda library becomes redundant, but that means it doesn't require any new features to be added to it. 显然,boost lambda库变得多余,但这意味着它不需要添加任何新功能。

I don't see how usage of lambda depends on support by libraries. 我没有看到lambda的使用取决于库的支持。 Lambdas eliminate the need to create many classes just to wrap different small algorithms and neatly fit together with other language/library features ( std::function comes to mind). Lambdas消除了创建许多类的需要,只是为了包装不同的小算法,并与其他语言/库特征巧妙地结合在一起( std::function浮现在脑海中)。 Wherever you used to pass either a function object or a function pointer, lambdas can be used, too. 无论您以前在哪里传递函数对象或函数指针,都可以使用lambdas。

So they mainly add another alternative for making use of existing code and libraries. 因此,他们主要添加另一种方法来利用现有的代码和库。 The only way I can see for libraries to better support lambda is use more functional-style approaches. 我可以看到库以更好地支持lambda的唯一方法是使用更多功能风格的方法。

Chances are such libraries are going to wait until there's proper compiler support for the relevant C++0x features , and not bother much with it until the mainstream compilers do support it. 有可能这样的库会等到相关的C ++ 0x功能有适当的编译器支持,并且在主流编译器支持它之前不会费心。 Don't hold your breath. 不要屏住呼吸。

This is NOT true, you cannot replace boost::lambda with C++0x lambda. 这不是真的,你不能用C ++ 0x lambda替换boost :: lambda。 See here for some reasons (about boost bind, but I think most of it transfers) 看到这里有一些原因(关于boost bind,但我认为大部分转移)

Also, @daniel this might help you get started using lambda functions/boost bind for slots. 此外,@ daniel 可能会帮助您开始使用lambda函数/ boost绑定槽。 It makes my life incredibly easy. 它让我的生活变得异常轻松。

Additionally, @litb from my sources, lambdas are not going to be changed (argh) 另外,@ litb来自我的消息来源,lambdas不会被改变(argh)

Most libraries use standard function pointers for callbacks. 大多数库使用标准函数指针进行回调。 C++0x lambdas can be used as function pointers, so most libraries wouldn't need to be modified. C ++ 0x lambdas可以用作函数指针,因此大多数库都不需要修改。 Other libraries use templates so they can take any callable object (eg std::foreach wouldn't need to be modified). 其他库使用模板,因此它们可以获取任何可调用对象(例如, std::foreach不需要修改)。

The only other C++0x feature that I can think of that libraries might change to is using strongly typed enums . 我能想到的唯一其他C ++ 0x功能库可能会改变为使用强类型enums Also, libraries might start to use extern templates to reduce compilation times. 此外,库可能会开始使用extern模板来减少编译时间。

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

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