使用自定義std :: set比較器我試圖將一組整數中的項的默認順序更改為lexicographic而不是numeric,并且我無法使用g ++進行以下編譯:file.cpp:bool lex_compare(const int64_t &a, const int64_t &b) {
stringstream s1,s2;
s1 << a;
s2 << b;
return s1.str() < s2.str();}void foo(){
set<int64_t, lex_compare> s;
s.insert(1);
...}我收到以下錯誤:error: type/value mismatch at argument 2 in template parameter list for ‘template<class _Key, class _Compare, class _Alloc> class std::set’error: expected a type, got ‘lex_compare’我究竟做錯了什么?
請問 使用自定義std :: set比較器
慕桂英4014372
2019-09-04 10:05:25