Boost BCCL容器算法实例
Boost BCCL Container Algorithm Working Example
是否有人请给出一个完整的(包括所有头文件)工作(编译)如何使用Boost BCCL的例子,例如一个boost::RandomAccessContainer
与std::sort在一起?
文档中给出的示例有什么问题?
当然,它不完整,但它应该是微不足道的编译…
更进一步,你的请求不能被满足:你想要std::sort
的概念检查,但是这个函数不能被重新定义。当然,您可以定义自己的排序函数,并使用文档中提供的BCCL代码:
#include <algorithm>
#include "boost/concept/requires.hpp"
template<typename I>
BOOST_CONCEPT_REQUIRES(
((Mutable_RandomAccessIterator<I>))
((LessThanComparable<typename Mutable_RandomAccessIterator<I>::value_type>)),
(void)) // return type
sort(I begin, I end)
{
std::sort(begin, end);
}
int main() {
int a[] = { 1, 4, 3, 2, 6, 5 };
sort(a, a + 6);
}
注意:我从未使用过BCCL。将上述内容整合在一起很简单,花了我不到五分钟的时间。当然你也可以这么做?
相关文章:
- 从C++实例化QML
- 在全局变量中保存类的实例以重新创建类(创建"backup")
- OpenGL - 在抛出"__gnu_cxx::recursive_init_error"实例后终止调用?
- 如何在c++中为模板函数实例创建快捷方式
- 为什么这个运算符<重载函数对 STL 算法不可见?
- 在C++中,是否可以基于给定的标识符创建基类的新实例,反之亦然
- 设计一个只能由特定类实例化的类(如果可能的话,通过make_unique)
- 基于ELO的团队匹配算法
- C++选择排序算法中的逻辑错误
- 如何创建一个空的全局类并在启动时实例化它
- 无法创建抽象类的实例
- 有没有办法将谓词中的元素偏移量传递给 std 算法?
- C++A*算法并不总是在路径中具有目标节点
- 多个文件的内存分配错误"在抛出 'std :: bad_alloc' what (): std :: bad_alloc 的实例后终止调用" [C++]
- 排序算法c++
- 在两个类中共享相同的函数调用,并在不需要时避免空实例化
- 我收到以下错误:抛出'std::bad_alloc'实例后终止调用
- 构建可组合有向图(扫描仪生成器的汤普森构造算法)
- 我们如何并行运行算法的 n 个实例并以有效的方式计算结果函数的平均值?
- Boost BCCL容器算法实例