[問題] 利用 boost 的 Lambda 取代 C++0x:Lam …
在網路看到一個範例
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;
int main(int argc, char** argv) {
vector<string> v;
v.push_back("What");
v.push_back("ever");
v.push_back("you");
v.push_back("want");
v.push_back("to");
v.push_back("be");
sort(v.begin(),v.end(),
[](const string& left,const string& right){
return left.size() < right.size();
}
);
}
這段 code 目前只能在 Visual Studio 2010 執行
我的環境是 Visual Stuio 2008 + boost Library
我想把這個 Lambda 的寫法用 boost 的 Lambda 替換
我很白癡的寫了這段
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iterator>
#include <boost/lambda/lambda.hpp>
#include <boost/tr1/functional.hpp>
using namespace std;
int main(int argc, char** argv) {
vector<string> v;
v.push_back("What");
v.push_back("ever");
v.push_back("you");
v.push_back("want");
v.push_back("to");
v.push_back("be");
sort(v.begin(),v.end(), _1 < _2);
}
結果不 work , 請教一下版上的高手如何實現
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.216.172.246
→
07/16 16:45, , 1F
07/16 16:45, 1F
推
07/16 16:49, , 2F
07/16 16:49, 2F
→
07/16 16:58, , 3F
07/16 16:58, 3F
→
07/16 17:05, , 4F
07/16 17:05, 4F
→
07/16 17:08, , 5F
07/16 17:08, 5F
→
07/16 17:08, , 6F
07/16 17:08, 6F
→
07/16 17:26, , 7F
07/16 17:26, 7F
推
07/16 17:35, , 8F
07/16 17:35, 8F
※ 編輯: spider391 來自: 117.19.104.114 (07/16 19:16)
→
07/18 15:26, , 9F
07/18 15:26, 9F
→
07/18 15:45, , 10F
07/18 15:45, 10F
→
07/18 15:45, , 11F
07/18 15:45, 11F
→
07/18 15:46, , 12F
07/18 15:46, 12F
推
07/18 15:55, , 13F
07/18 15:55, 13F
→
07/19 10:05, , 14F
07/19 10:05, 14F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章