目前,我試圖生成的組合,我用下面的代碼:我需要什麼庫來使用std ::佔位符?
#include <vector>
#include <algorithm>
#include <iostream>
#include <functional>
template<class RandIt, class Compare>
bool next_combination(RandIt first, RandIt mid, RandIt last)
{
std::sort(mid, last, std::bind(std::less<int>(), std::placeholders::_2
, std::placeholders::_1));
return std::next_permutation(first, last, std::less<int>());
}
使用G ++也無法編譯說:
next_combo.cpp: In function ‘bool next_combination(RandIt, RandIt, RandIt)’:
next_combo.cpp:10: error: ‘bind’ is not a member of ‘std’
next_combo.cpp:10: error: ‘std::placeholders’ has not been declared
next_combo.cpp:11: error: ‘std::placeholders’ has not been declared
我認爲的std ::佔位符是在功能性聲明,但現在我很困惑。 我應該只使用boost嗎?
此外,項目的其餘部分是使用C++ 0x,那麼有沒有更好的方式來使用C++ 0x功能編寫這個?
任何幫助非常感謝:)
你必須在你的g ++編譯器中使用C++ 0x標誌來獲取這些標誌。或者boost :: bind。 – Anycorn 2010-12-23 07:34:00
@aaa,謝謝,看起來它已經解決了我的問題。 – shuttle87 2010-12-23 07:36:23