rabbitfoot530's diary

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

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

空白削除

空白をstd::stringから削除。 std::string str = " ab "; boost::trim(str); 文字指定する場合は std::string str = " ab "; boost::trim_if(str, boost::is_any_of(" "));

sleep

wait処理をしたいとき、sleepでやってもいいけど、boostでやるなら、下記のよう。 #include <boost/thread.hpp> #include <boost/date_time/posix_time/posix_time.hpp> while (true) { boost::this_thread::sleep(boost::posix_time::milliseconds(1000); std::cout << "hi" << std::endl; }</boost/date_time/posix_time/posix_time.hpp></boost/thread.hpp>