C++标准/事实上的 STL 算法包装器
是否有任何围绕标准算法的标准/事实上的标准(增强)包装器,可以与定义开始和结束的容器一起使用。让我向您展示代码的含义:
// instead of specifying begin and end
std::copy(vector.begin(), vector.end(), output);
// write as
xxx::copy(vector, output);
我知道它可以很容易编写,但我正在专门寻找无处不在的东西。 谢谢。
Are there any standard/de facto standard (boost) wrappers around standard algorithms which work with containers defining begin and end. Let me show you what I mean with the code:
// instead of specifying begin and end
std::copy(vector.begin(), vector.end(), output);
// write as
xxx::copy(vector, output);
I know it can be written easily, but I am looking specifically for something ubiquitous.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Boost Range 库有一个名为 RangeEx 的扩展,其中包含所有 stl 算法的范围包装器,以及一些新算法。
它最近已被 Boost 接受,因此尚未出现在当前的“官方”版本 (1.41) 中。在此更改之前,您可以从 Boost Vault 下载最新版本。
不知道这是否会成为 C++ 标准的一部分,但它在 Boost 中的事实意味着它将成为事实上的标准。
There is an extension to the Boost Range library called RangeEx which contains range wrappers for all stl algorithms, plus some new ones.
It has recently been accepted into Boost and so it's not yet in the current "official" release (1.41). Until this changes, you can download the latest version from the Boost Vault.
Don't know if this will ever become part of the C++ standard, but the fact that it's in Boost means that it will be the de facto standard.
下一个标准将(希望如此!)修正这一点。同时,请查看 Boost.Range 及其各种用途,尽管我不知道标准算法的接口。
The next standard will (hopefully!) amend this. In the meantime, take a look at Boost.Range and its various uses although I’m not aware of an interface to the standard algorithms.
我见过类似情况的唯一情况是那些基于 boost::range 库的算法,但即使这些算法实际上也没有修改像 std::copy 这样的标准算法code> 或
std::remove_if
——需要编写有问题的算法来利用这样的范围包装器。有关示例,请参阅 Boost 字符串算法 库。
The only case where I've seen something like this are those algorithms based upon the
boost::range
library, but even these do not actually modify the standard algorithms likestd::copy
orstd::remove_if
-- the algorithm in question needs to be written to take advantage of such a range wrapper.For an example, see the Boost String Algorithms library.
我将添加我自己的发现:Adobe源库(Boost中的rangex取代算法部分)
ASL
I will add my own finding: Adobe source libraries (rangex from boost supersedes algorithms part)
ASL