看板 C_and_CPP 關於我們 聯絡資訊
※ 引述《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 ([email protected]) 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
spider391:感謝,我之前一直試 bind 但是還不太了解它的使用方式^^ 07/17 09:51
loveme00835:好神奇 ( ̄▽ ̄#)﹏﹏ 07/17 10:00