有人可以给出一个完整的(包括所有头文件)工作(编译)示例,说明如何在例如 aboost::RandomAccessContainer
和 std::sort 上使用 Boost BCCL?
问问题
331 次
1 回答
3
文档中给出的示例有什么问题?
诚然,它并不完整,但让它编译起来应该很简单……</p>
此外,您的请求无法满足:您想要对 进行概念检查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。把上面的东西一起破解是微不足道的,我花了不到五分钟的时间。当然你也可以这样做吗?
于 2011-07-11T13:50:23.967 回答