Re: [問題] 利用 boost 的 Lambda 取代 C++0x:Lam …
※ 引述《spider391 (小乖)》之銘言:
: #include <iostream>
: #include <string>
: #include <algorithm>
: #include <vector>
: #include <iterator>
: #include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
: using namespace std;
using namespace boost::lambda;
: 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(),
bind(&string::size, _1) < bind(&string::size, _2));
: }
bind 在這種場合的用法:
bind(成員函式指標, 物件參考或物件指標, 不定參數)
推文很難改你的 code 所以用回的。
--
Ling-hua Tseng (uranus@tinlans.org)
Department of Computer Science, National Tsing-Hua University
Interesting: C++, Compiler, PL/PD, OS, VM, Large-scale software design
Researching: Software pipelining for VLIW architectures
Homepage: http://www.tinlans.org
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.160.104.245
推
07/17 09:51, , 1F
07/17 09:51, 1F
推
07/17 10:00, , 2F
07/17 10:00, 2F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章