2011-07-11 30 views

回答

3

文档中给出的示例有什么问题?

当然,这不是完整的,但它应该是微不足道得到它编译...

此外,您的要求不能得到满足:想要概念检查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。一起黑客攻击并不重要,只花了不到五分钟。当然你可以做同样的事情?

+0

+1你的笔记 – ildjarn

+0

这不会在我的Ubuntu 11.04上使用GCC 4.6.1进行编译: –