5

現在、いくつかの整数を含むベクトルから組み合わせを生成しようとしています。今のところ、to_generate の長さのすべての組み合わせを出力したいと考えています。std::next_permutation を使用して組み合わせを生成するC++ の組み合わせと順列で、このコードを見つけました。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);
}

私はそれを次のように呼んでみました:

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 << " ";
        }
    }
}

しかし、巨大な stl garbled エラー メッセージが表示されます。ここで本当に明らかに間違っていることはありますか?

std::placeholder はどのヘッダーを見つけることができますか?

要求どおり、エラー メッセージは次のとおりです。

$メイク
g++ -g -std=c++0x -I /usr/lib/ -c Equity.cpp
/usr/include/c++/4.4/algorithm:62 からインクルードされたファイルで、
                 misc.hpp:6 から、
                 エクイティ.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]' からインスタンス化されました
Equity.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 から、
                 エクイティ.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]' からインスタンス化されました
Equity.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:   instantiated from ‘void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator > >, _Compare = std::_Bind, std::_Placeholder)>]’
misc.hpp:13:   instantiated from ‘bool next_combination(RandIt, RandIt, RandIt, Compare) [with RandIt = __gnu_cxx::__normal_iterator > >, Compare = bool]’
equity.cpp:28:   instantiated from here
/usr/include/c++/4.4/tr1_impl/functional:195: error: ‘volatile bool’ is not a class, struct, or union type
/usr/include/c++/4.4/tr1_impl/functional: In instantiation of ‘std::_Result_of_impl’:
/usr/include/c++/4.4/tr1_impl/functional:149:   instantiated from ‘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]' からインスタンス化されました
Equity.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]' からインスタンス化されました
Equity.cpp:28: ここからインスタンス化
/usr/include/c++/4.4/tr1_impl/functional:195: エラー: 'bool' はクラス、構造体、または共用体型ではありません
/usr/include/c++/4.4/algorithm:62 からインクルードされたファイルで、
                 misc.hpp:6 から、
                 エクイティ.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]' からインスタンス化されました
Equity.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 から、
                 エクイティ.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_pa​​rtition(_RandomAccessIterator, _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: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]' からインスタンス化されました
Equity.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_pa​​rtition(_RandomAccessIterator, _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: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]' からインスタンス化されました
Equity.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_pa​​rtition(_RandomAccessIterator, _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: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]' からインスタンス化されました
Equity.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_pa​​rtition(_RandomAccessIterator, _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: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]' からインスタンス化されました
Equity.cpp:28: ここからインスタンス化
/usr/include/c++/4.4/tr1_impl/functional:195: エラー: 'bool' はクラス、構造体、または共用体型ではありません
/usr/include/c++/4.4/algorithm:62 からインクルードされたファイルで、
                 misc.hpp:6 から、
                 エクイティ.cpp:3 から:
/usr/include/c++/4.4/bits/stl_algo.h: 関数 '_RandomAccessIterator std::__unguarded_pa​​rtition(_RandomAccessIterator, _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: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]' からインスタンス化されました
Equity.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]' からインスタンス化されました
Equity.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]' からインスタンス化されました
Equity.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]' からインスタンス化されました
Equity.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 から、
                 エクイティ.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:: _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]' からインスタンス化されました
Equity.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 _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Distance = long int, _Tp = int、_Compare = std::_Bind、std::_Placeholder)>]':
/usr/include/c++/4.4/bits/stl_heap.h:316: '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:: _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]' からインスタンス化されました
Equity.cpp:28: ここからインスタンス化
/usr/include/c++/4.4/bits/stl_heap.h:180: エラー: '(std::_Bind, std::_Placeholder)>) (int&, int&)' の呼び出しに一致しません
make: *** [equity.o] エラー 1
4

1 に答える 1

3

2 番目のテンプレート引数は であってはなりません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 << " ";

スペースを使用すると、コードの見栄えが良くなります。

于 2010-12-14T17:02:43.207 に答える