stdbind

    10熱度

    2回答

    我想bind()從派生類的基類的函數版本。該功能在底座中被標記爲受保護。當我這樣做的時候,代碼在Clang(Apple LLVM Compiler 4.1)中編譯得很愉快,但是在g ++ 4.7.2和Visual Studio 2010中都出現了一個錯誤。錯誤是:''Base :: foo':can not訪問受保護的成員「。 含義是引用的上下文實際上在bind()之內,當然這個函數被視爲受保護的

    11熱度

    1回答

    我有一個成員函數與幾個參數。我想將它綁定到特定的對象實例並將其傳遞給另一個函數。我可以用佔位符做到這一點: // actualInstance is a MyClass* auto callback = bind(&MyClass::myFunction, actualInstance, _1, _2, _3); 但是,這是一個有點笨拙 - 一,當參數變化的次數,我不得不改變所有的綁定電話也

    7熱度

    3回答

    我使用GCC 4.6.3互動,並試圖生成下面的代碼的隨機數: #include <random> #include <functional> int main() { std::mt19937 rng_engine; printf("With bind\n"); for(int i = 0; i < 5; ++i) { std::uniform_

    7熱度

    2回答

    (注:正如應該已經從標籤清楚,這是嚴格C++ 03是的,我知道,拉姆達使得這一切痛苦消失(在新帶來的種類,我打賭),但這是一個嵌入式系統,具有90年代的操作系統版本,我被告知應該很高興我有一個C++ 03編譯器(GCC4.1.x,BTW)或C++因此,請放棄發佈C++ 11解決方案,不需要蹭它,真的。 另外,std::bind(),std::function()等當然實際上在std::tr1,但我

    10熱度

    2回答

    的,我需要做這樣的事情往往比更多的元件組合: AsyncOperation * pAsyncOperation = new AsyncOperation(); auto bindOperation = std::bind(&AsyncOperation::operator(), std::ref(*pAsyncOperation)); std::thread thread(bindOperat

    3熱度

    1回答

    如何在__stdcall函數上使用std :: bind(而不是boost :: bind),或者在當前的實現中甚至可以使用它? 當我試圖編譯下面的例子: std::function<LRESULT __stdcall(int, WPARAM, LPARAM)> func; func = std::bind(&EventListener::myhook, this, std::placehold

    1熱度

    1回答

    std :: bind的返回類型是(有意)未指定的。它在std :: function中是可存儲的。 下面的示例程序演示瞭如何將std :: bind()返回的臨時對象顯式轉換爲std :: function以調用fn1()。 如果std :: bind的返回類型是可知的,我可以重載回調構造函數&將不再需要顯式強制轉換std :: bind臨時對象。 有什麼辦法可以避免顯式轉換嗎? // g++

    3熱度

    1回答

    林欲以std::bind結合this到方法,該方法在QtConcurrent::blockingMapped 部首使用: class TuringMachine { private: TRTable table; std::set<ConfigNode*> currentConfigs; //function object std::function<

    10熱度

    4回答

    C++中的大部分內容都是0,而不是1。出於好奇,爲什麼佔位符1基於?含義_1是第一個參數,而不是_0。

    4熱度

    1回答

    很適合我的另一個令人不安的錯誤信息,如果我理解的std ::綁定正確,我可以像參數來_1的限定非定的參數?對?那麼考慮下面這一行: std::function<bool(value_type, const std::string &)> func(std::bind(&Pred, _1, "name")); 這應該工作吧?這將被用於一個std :: find_if()函數