Retourner au contenu associé (journal : Mono pour Android en version 1.0)
Posté par Batchyx le 10 avril 2011 à 23:31. En réponse au journal Mono pour Android en version 1.0. Évalué à 3.
#include <boost/function.hpp> #include <boost/bind.hpp> #include <iostream> typedef boost::function<int(int,int)> OperationDelegate; struct Console { void Print(OperationDelegate del) { int res = del(42,3); // appel safe pasque gnagnagna std::cout << res << std::endl; } }; class Exemple { int i; public: Exemple() : i(42) {} int add(int a, int b) { return a + b + i; } int add3(int a, int LOL, int b) { return (a + b + i)*LOL; } void Test() { Console c; c.Print(boost::bind(&Exemple::add, this, _1, _2)); c.Print(boost::bind(&Exemple::add3, this, _1, 1 /* valeur de LOL */, _2)); // variante inline pour c++11 c.Print([](int x, int y) { return x + y; }); } };
Oui, et ensuite ?
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
[^] # Re: Je tiendrai jusqu'à demain
Posté par Batchyx . En réponse au journal Mono pour Android en version 1.0. Évalué à 3.
Oui, et ensuite ?