shu*_*e87 5 c++ message formatted
目前我正在尝试从包含一些整数的向量生成组合。现在我希望它打印出所有长度为 to_generate 的组合。我在 C++中的组合和排列中发现了这段代码,它使用 std::next_permutation 来生成组合。next_combination 代码如下:
template<class RandIt, class Compare>
bool next_combination(RandIt first, RandIt mid, RandIt last, Compare comp)
{
std::sort(mid, last, std::tr1::bind(comp, std::tr1::placeholders::_2
, std::tr1::placeholders::_1));
return std::next_permutation(first, last, comp);
}
Run Code Online (Sandbox Code Playgroud)
我试着这样称呼它:
bool mycomp (int c1, int c2)
{ return (c1)<(c2); }
void test_combos(int to_generate){
std::vector<int> combo(30);
for(int i=0;i<30;++i){
combo.push_back(i);
}
while(next_combination<std::vector<int>::iterator, bool>(combo.begin(),combo.begin()+to_generate,combo.end(),mycomp)){
for(std::vector<int>::iterator iter = combo.begin(); iter != combo.end() ; ++iter){
std::cout << *iter << " ";
}
}
}
Run Code Online (Sandbox Code Playgroud)
但我收到一条巨大的 stl 乱码错误消息。这里有什么明显的问题吗?
我可以找到哪些标头 std::placeholder?
根据要求,这是错误消息:
$ make
g++ -g -std=c++0x -I /usr/lib/ -cEquity.cpp
在 /usr/include/c++/4.4/algorithm:62 包含的文件中,
来自 misc.hpp:6,
来自equity.cpp:3:
/usr/include/c++/4.4/bits/stl_algo.h:在函数'bool std::next_permutation(_BIter, _BIter, _Compare) [with _BIter = __gnu_cxx::__normal_iterator > >, _Compare = bool]'中:
misc.hpp:15: 从'bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator >>, Compare = bool]' 实例化
股权.cpp:28:从这里实例化
/usr/include/c++/4.4/bits/stl_algo.h:3655: 错误: '__comp' 不能用作函数
/usr/include/c++/4.4/bits/stl_algo.h:3658: 错误: '__comp' 不能用作函数
在 /usr/include/c++/4.4/functional:70 包含的文件中,
来自 /usr/include/c++/4.4/memory:70,
来自 /usr/include/boost/config/no_tr1/memory.hpp:21,
来自 /usr/include/boost/get_pointer.hpp:12,
来自 /usr/include/boost/bind/mem_fn.hpp:25,
来自 /usr/include/boost/mem_fn.hpp:22,
来自 /usr/include/boost/bind/bind.hpp:26,
来自 /usr/include/boost/bind.hpp:22,
来自 misc.hpp:4,
来自equity.cpp:3:
/usr/include/c++/4.4/tr1_impl/functional:在全局范围内:
/usr/include/c++/4.4/tr1_impl/functional: 在 'std::_Result_of_impl' 的实例化中:
/usr/include/c++/4.4/tr1_impl/functional:149: 从 'std::result_of' 实例化
/usr/include/c++/4.4/bits/stl_algo.h:124: 从 'const _Tp& std::__median(const _Tp&, const _Tp&, const _Tp&, _Compare) 实例化 [with _Tp = int, _Compare = std::_Bind , std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:2301:从'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Size = long int, _Compare = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:5258:从'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std::_Placeholder)>]'
misc.hpp:13: 从'bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator >>, Compare = bool]' 实例化
股权.cpp:28:从这里实例化
/usr/include/c++/4.4/tr1_impl/functional:195: 错误:'const volatile bool' 不是类、结构或联合类型
/usr/include/c++/4.4/tr1_impl/functional: 在 'std::_Result_of_impl' 的实例化中:
/usr/include/c++/4.4/tr1_impl/functional:149: 从 'std::result_of' 实例化
/usr/include/c++/4.4/bits/stl_algo.h:124: 从 'const _Tp& std::__median(const _Tp&, const _Tp&, const _Tp&, _Compare) 实例化 [with _Tp = int, _Compare = std::_Bind , std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:2301:从'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Size = long int, _Compare = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:5258:从'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std::_Placeholder)>]'
misc.hpp:13: 从'bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator >>, Compare = bool]' 实例化
股权.cpp:28:从这里实例化
/usr/include/c++/4.4/tr1_impl/functional:195: 错误:'volatile bool' 不是类、结构或联合类型
/usr/include/c++/4.4/tr1_impl/functional: 在 'std::_Result_of_impl' 的实例化中:
/usr/include/c++/4.4/tr1_impl/functional:149: 从 'std::result_of' 实例化
/usr/include/c++/4.4/bits/stl_algo.h:124: 从 'const _Tp& std::__median(const _Tp&, const _Tp&, const _Tp&, _Compare) 实例化 [with _Tp = int, _Compare = std::_Bind , std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:2301:从'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Size = long int, _Compare = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:5258:从'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std::_Placeholder)>]'
misc.hpp:13: 从'bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator >>, Compare = bool]' 实例化
股权.cpp:28:从这里实例化
/usr/include/c++/4.4/tr1_impl/functional:195: 错误:'const bool' 不是类、结构或联合类型
/usr/include/c++/4.4/tr1_impl/functional: 在 'std::_Result_of_impl' 的实例化中:
/usr/include/c++/4.4/tr1_impl/functional:149: 从 'std::result_of' 实例化
/usr/include/c++/4.4/bits/stl_algo.h:124: 从 'const _Tp& std::__median(const _Tp&, const _Tp&, const _Tp&, _Compare) 实例化 [with _Tp = int, _Compare = std::_Bind , std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:2301:从'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Size = long int, _Compare = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:5258:从'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std::_Placeholder)>]'
misc.hpp:13: 从'bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator >>, Compare = bool]' 实例化
股权.cpp:28:从这里实例化
/usr/include/c++/4.4/tr1_impl/functional:195: 错误:'bool' 不是类、结构或联合类型
在 /usr/include/c++/4.4/algorithm:62 包含的文件中,
来自 misc.hpp:6,
来自equity.cpp:3:
/usr/include/c++/4.4/bits/stl_algo.h: 在函数 'const _Tp& std::__median(const _Tp&, const _Tp&, const _Tp&, _Compare) [with _Tp = int, _Compare = std::_Bind, std ::_Placeholder)>]':
/usr/include/c++/4.4/bits/stl_algo.h:2301:从'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Size = long int, _Compare = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:5258:从'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std::_Placeholder)>]'
misc.hpp:13: 从'bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator >>, Compare = bool]' 实例化
股权.cpp:28:从这里实例化
/usr/include/c++/4.4/bits/stl_algo.h:124: 错误:不匹配调用'(std::_Bind, std::_Placeholder)>) (const int&, const int&)'
/usr/include/c++/4.4/bits/stl_algo.h:125: 错误:不匹配调用 '(std::_Bind, std::_Placeholder)>) (const int&, const int&)'
/usr/include/c++/4.4/bits/stl_algo.h:127: 错误:不匹配调用 '(std::_Bind, std::_Placeholder)>) (const int&, const int&)'
/usr/include/c++/4.4/bits/stl_algo.h:131: 错误:不匹配调用'(std::_Bind, std::_Placeholder)>) (const int&, const int&)'
/usr/include/c++/4.4/bits/stl_algo.h:133: 错误:不匹配调用'(std::_Bind, std::_Placeholder)>) (const int&, const int&)'
在 /usr/include/c++/4.4/functional:70 包含的文件中,
来自 /usr/include/c++/4.4/memory:70,
来自 /usr/include/boost/config/no_tr1/memory.hpp:21,
来自 /usr/include/boost/get_pointer.hpp:12,
来自 /usr/include/boost/bind/mem_fn.hpp:25,
来自 /usr/include/boost/mem_fn.hpp:22,
来自 /usr/include/boost/bind/bind.hpp:26,
来自 /usr/include/boost/bind.hpp:22,
来自 misc.hpp:4,
来自equity.cpp:3:
/usr/include/c++/4.4/tr1_impl/functional:在全局范围内:
/usr/include/c++/4.4/tr1_impl/functional: 在 'std::_Result_of_impl' 的实例化中:
/usr/include/c++/4.4/tr1_impl/functional:149: 从 'std::result_of' 实例化
/usr/include/c++/4.4/bits/stl_algo.h:2230:从 '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, _Tp, _Compare) 实例化 [with _RandomAccessIterator = __gnu_cxx::__normal_Terator > = >, int = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:2301:从'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Size = long int, _Compare = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:5258:从'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std::_Placeholder)>]'
misc.hpp:13: 从'bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator >>, Compare = bool]' 实例化
股权.cpp:28:从这里实例化
/usr/include/c++/4.4/tr1_impl/functional:195: 错误:'const volatile bool' 不是类、结构或联合类型
/usr/include/c++/4.4/tr1_impl/functional: 在 'std::_Result_of_impl' 的实例化中:
/usr/include/c++/4.4/tr1_impl/functional:149: 从 'std::result_of' 实例化
/usr/include/c++/4.4/bits/stl_algo.h:2230:从 '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, _Tp, _Compare) 实例化 [with _RandomAccessIterator = __gnu_cxx::__normal_Terator > = >, int = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:2301:从'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Size = long int, _Compare = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:5258:从'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std::_Placeholder)>]'
misc.hpp:13: 从'bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator >>, Compare = bool]' 实例化
股权.cpp:28:从这里实例化
/usr/include/c++/4.4/tr1_impl/functional:195: 错误:'volatile bool' 不是类、结构或联合类型
/usr/include/c++/4.4/tr1_impl/functional: 在 'std::_Result_of_impl' 的实例化中:
/usr/include/c++/4.4/tr1_impl/functional:149: 从 'std::result_of' 实例化
/usr/include/c++/4.4/bits/stl_algo.h:2230:从 '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, _Tp, _Compare) 实例化 [with _RandomAccessIterator = __gnu_cxx::__normal_Terator > = >, int = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:2301:从'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Size = long int, _Compare = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:5258:从'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std::_Placeholder)>]'
misc.hpp:13: 从'bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator >>, Compare = bool]' 实例化
股权.cpp:28:从这里实例化
/usr/include/c++/4.4/tr1_impl/functional:195: 错误:'const bool' 不是类、结构或联合类型
/usr/include/c++/4.4/tr1_impl/functional: 在 'std::_Result_of_impl' 的实例化中:
/usr/include/c++/4.4/tr1_impl/functional:149: 从 'std::result_of' 实例化
/usr/include/c++/4.4/bits/stl_algo.h:2230:从 '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, _Tp, _Compare) 实例化 [with _RandomAccessIterator = __gnu_cxx::__normal_Terator > = >, int = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:2301:从'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Size = long int, _Compare = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:5258:从'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std::_Placeholder)>]'
misc.hpp:13: 从'bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator >>, Compare = bool]' 实例化
股权.cpp:28:从这里实例化
/usr/include/c++/4.4/tr1_impl/functional:195: 错误:'bool' 不是类、结构或联合类型
在 /usr/include/c++/4.4/algorithm:62 包含的文件中,
来自 misc.hpp:6,
来自equity.cpp:3:
/usr/include/c++/4.4/bits/stl_algo.h: 在函数 '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Tre _Comp = int, ::_Bind, std::_Placeholder)>]':
/usr/include/c++/4.4/bits/stl_algo.h:2301:从'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Size = long int, _Compare = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:5258:从'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std::_Placeholder)>]'
misc.hpp:13: 从'bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator >>, Compare = bool]' 实例化
股权.cpp:28:从这里实例化
/usr/include/c++/4.4/bits/stl_algo.h:2230: 错误:不匹配调用'(std::_Bind, std::_Placeholder)>) (int&, int&)'
/usr/include/c++/4.4/bits/stl_algo.h:2233: 错误:不匹配调用 '(std::_Bind, std::_Placeholder)>) (int&, int&)'
/usr/include/c++/4.4/bits/stl_algo.h: 在函数 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std: :_Placeholder)>]':
/usr/include/c++/4.4/bits/stl_algo.h:2193: 从 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) 实例化 [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Compare, = std::_Bind std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:5260:从'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std::_Placeholder)>]'
misc.hpp:13: 从'bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator >>, Compare = bool]' 实例化
股权.cpp:28:从这里实例化
/usr/include/c++/4.4/bits/stl_algo.h:2128: 错误:不匹配调用 '(std::_Bind, std::_Placeholder)>) (int&, int&)'
/usr/include/c++/4.4/bits/stl_algo.h: 在函数 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Compare = std::_Bind, std::_Placeholder)>]':
/usr/include/c++/4.4/bits/stl_algo.h:5108: 从 'void std::partial_sort(_RAIter, _RAIter, _RAIter, _Compare) 实例化 [with _RAIter = __gnu_cxx::__normal_iterator > >, _Compare = std:: _Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:2288: 从 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) 实例化 [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Size = long int, _Compare = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:5258:从'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std::_Placeholder)>]'
misc.hpp:13: 从'bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator >>, Compare = bool]' 实例化
股权.cpp:28:从这里实例化
/usr/include/c++/4.4/bits/stl_algo.h:1919: 错误:不匹配调用 '(std::_Bind, std::_Placeholder)>) (int&, int&)'
/usr/include/c++/4.4/bits/stl_algo.h: 在函数 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator >>, _Tp = int, _Compare = std:: _Bind, std::_Placeholder)>]':
/usr/include/c++/4.4/bits/stl_algo.h:2134: 从 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) 实例化 [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Compare = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:2193: 从 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) 实例化 [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Compare, = std::_Bind std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:5260:从'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std::_Placeholder)>]'
misc.hpp:13: 从'bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator >>, Compare = bool]' 实例化
股权.cpp:28:从这里实例化
/usr/include/c++/4.4/bits/stl_algo.h:2084: 错误:不匹配调用 '(std::_Bind, std::_Placeholder)>) (int&, int&)'
在 /usr/include/c++/4.4/bits/stl_algo.h:62 包含的文件中,
来自 /usr/include/c++/4.4/algorithm:62,
来自 misc.hpp:6,
来自equity.cpp:3:
/usr/include/c++/4.4/bits/stl_heap.h: 在函数 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Distance = long int, _Tp = int, _Compare = std::_Bind, std::_Placeholder)>]':
/usr/include/c++/4.4/bits/stl_heap.h:434: 从 'void std::make_heap(_RAIter, _RAIter, _Compare) 实例化 [with _RAIter = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:1917: 从 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) 实例化 [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Compare = std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) _Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:5108: 从 'void std::partial_sort(_RAIter, _RAIter, _RAIter, _Compare) 实例化 [with _RAIter = __gnu_cxx::__normal_iterator > >, _Compare = std:: _Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:2288: 从 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) 实例化 [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Size = long int, _Compare = std::_Bind, std::_Placeholder)>]'
/usr/include/c++/4.4/bits/stl_algo.h:5258:从'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator >>, _Compare = std::_Bind, std::_Placeholder)>]'
misc.hpp:13: 从'bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator >>, Compare = bool]' 实例化
股权.cpp:28:从这里实例化
/usr/include/c++/4.4/bits/stl_heap.h:303: 错误:不匹配调用 '(std::_Bind, std::_Placeholder)>) (int&, int&)'
/usr/include/c++/4.4/bits/stl_heap.h: 在函数 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAcces
第二个模板参数不应该是bool. 您可以允许编译器处理类型并简单地编写:
while(next_combination(combo.begin(), combo.begin() + to_generate, combo.end(), std::less<int>()))
for(std::vector<int>::iterator iter = combo.begin(); iter != combo.end() ; ++iter)
std::cout << *iter << " ";
Run Code Online (Sandbox Code Playgroud)
并使用空格——它使代码看起来更好。