基本上就是我想要做的是這樣的:延遲函數調用
std::function< int(void) > foo = &getInt;
int magicNumber = 13;
std::function< int(void) > delayedAdd = std::bind(std::plus, magicNumber, getInt);
顯然,這是行不通的。我需要以某種方式包裝getInt
調用,以便它恰好在std::plus
函數發生之前發生。然後,所有這些都需要推遲,直到我撥打delayedAdd
。
我正在QObject之外使用Qt5.0所以我不能connect
一個lambda到SLOT
。但我想要connect
,而不是delayedAdd
到SLOT
。
+標籤funception
Gadzooks!剛剛發生了什麼?什麼類型的綁定返回加號?我認爲綁定返回了一個函數對象! –
有一些事情,你只是不想知道;) –
更嚴重的是,http://stackoverflow.com/questions/6412065/what-is-the-return-type-of-boostbind觸及這個問題,但沒有提供很多細節 –