2009-12-31から1日間の記事一覧

boost::tieでtupleを展開

C++

参考:http://www.gesource.jp/weblog/?p=1654前の http://d.hatena.ne.jp/shokai/20091231/1262248887 をboost::tieで受け取ってみた tupletest.cpp #include <iostream> #include <string> #include <boost/tuple/tuple.hpp> using namespace std; using namespace boost; // 多値を返す tuple<int, double, string> test_</int,></boost/tuple/tuple.hpp></string></iostream>…

boost::tupleで多値を受け取る

C++

簡単だった。もっと早く使ってれば良かった。画像処理は座標とかサイズを複数返したい時がよくあるから 関数宣言とmake_tupleの引数の数が違うとコンパイル時にエラーになる。intやdoubleは混ぜるとcastされる。tupletest.cpp #include <iostream> #include <string> #include <boost/tuple/tuple.hpp></boost/tuple/tuple.hpp></string></iostream>…