rabbitfoot530's diary

読んだ本と、プログラムに関することのメモです。好きな言語は、C++, Python, Golang, TypeScript。数学・物理・学習理論も好きです。

2012-04-15から1日間の記事一覧

boost::threadから返り値を取得

boost::threadにfuncを指定して、funcからの戻り値を取得。funcには、引数を渡すために、bindする。 int return_func(std::string a, std::string b) { retrun 0; } boost::packaged_task<int> pt(boost::bind(return_func, "a", "b")); boost::unique_future<int> uf </int></int>…

key, valueのペアの格納と取り出し

key, valueをpairで格納しておいて、それを取り出すときは、tieでひとまとめにしてとりだす。 #include <boost/container/vector.hpp> #include <boost/tuple/tuple.hpp> boost::container::vector<std::string, std::string> v; std::string key, value; BOOST_FOREACH(boost::tie(key, value), v) { std::cout << key << value << std::en</std::string,></boost/tuple/tuple.hpp></boost/container/vector.hpp>…