2008-01-11から1日間の記事一覧

tupleの要素参照

C++

東方算程譚 - 型推論のオマケ TR1のtupleにはメンバ関数版のget()がない #include <string> #include <boost/tr1/tuple.hpp> // C++0xでは<tuple> using namespace std; using namespace std::tr1; int main() { tuple<int, int, string> person = make_tuple(1, 22, "Akira"); ++person.get<0>(); // エラー! ++get</int,></tuple></boost/tr1/tuple.hpp></string>…

functionとbindの組み合わせ

C++

東方算程譚 - delegateもどき functionとbindを組み合わせて使うとなかなかおもしろいことができる #include <iostream> #include <boost/tr1/functional.hpp> // C++0xでは<functional> using namespace std; using namespace std::tr1; int add(int lhs, int rhs) { return lhs + rhs; } int main() { funct</functional></boost/tr1/functional.hpp></iostream>…