boost

c++でプログレス・バーを表示する方法

boost の boost/progress.hpp を使えばOK #include <boost/progress.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/thread/thread.hpp> int main(int argc,char *argv[]) { const unsigned long expected_count=100; boost::progress_display show_progress( expected_count ); for(int i=0; i</boost/thread/thread.hpp></boost/date_time/posix_time/posix_time.hpp></boost/progress.hpp>

boost 1.50.0 移行メモ

boost-1.50.0 へ乗り換えました.移行方法をメモします. 1.50.0 での変更箇所 http://www.boost.org/users/history/version_1_50_0.html に一覧がありますが,機能追加・バグ修正・仕様変更と色々変わっています.特に大きな変更点としては,boost::filesys…

crcの計算

c++ で CRCを計算するコード.boost の crc.hpp を使います #include <iostream> #include <cassert> #include <boost/crc.hpp> using namespace std; int main() { const char *data = "hello boost/crc.hpp"; const size_t len = sizeof(data); // CRC-CCITT boost::crc_basic<16> crc1( 0x10</boost/crc.hpp></cassert></iostream>…

boost/accumulators

C/C++で、平均値、最大値、最小値、分散、中央値等の統計量を計算するなら、boost::accumulators が便利。2017年6月13日追記.情報が古かったので更新しました #include <iostream> #include <boost/accumulators/accumulators.hpp> #include <boost/accumulators/statistics.hpp> using namespace boost::accumulators; int main() { accumulato</boost/accumulators/statistics.hpp></boost/accumulators/accumulators.hpp></iostream>…

boost/format.hpp

iostream って使いにくい。特に浮動小数点数を使う時は printf系に分がある気がする。たとえば以下のCのコードも #include <stdio.h> int main() { printf("%10d\n", 12345); printf("%10.3f\n", 12.345); printf("%10.6f\n", 12.345); return 0; } std::cout を使う</stdio.h>…

boostのインストール方法(windowsの場合)

Windowsに、boostのライブラリとヘッダファイルをインストールする方法です。 ライブラリのビルド 先ず以下の手順で ライブラリをビルドします。 予め Visual studio express edition 等の開発環境をインストールしておく http://www.boost.org/ から最新の…

boostのcondition variable(条件変数)

Linuxだと pthread_cond_wait() つまり POSIX系、 Windows だと WaitForSingleObject() つまり Win32APIと、スレッドまわりのAPIはOSによって使い分ける必要があります。これは面倒くさい!!そういう場合は boost の boost::thread 一派が便利です。たとえば…