vector<int> vwInts;
vector<int> vwIntsB;
for(int i=0; i<10; i++)
vwInts.push_back(i);
transform(vwInts.begin(), vwInts.end(), inserter(vwIntsB, vwIntsB.begin()),
bind1st(plus<int>(), 5)); // method one
transform(vwInts.begin(), vwInts.end(), inserter(vwIntsB, vwIntsB.begin()),
bind2nd(plus<int>(), 5)); // method two
我知道bind1st和bind2nd之間的用法區別,方法一和方法二都爲我提供了預期的結果。使用bind1st或bind2nd?
在這種情況下(即轉換的用法)是否真的沒有太大的區別,以便我可以使用bind1st或bind2nd?
因爲,我迄今爲止看到的所有例子總是使用方法二。我想知道在上述情況下bind1st和bind2nd是否相同。
是相同的,我會建議你尋找到的boost ::綁定如果你還沒有。它比bind1st和bind2nd更靈活,更強大。 –