2007年4月19日 星期四

新一代 C++ Standard Library 2.0 : Boost

Boost 是新一代的 C++ Standard,最初由熱心的 C++ 標準委員會所創立,加上 C++ 社群的努力開發,組成了 Boost 程式庫.這些開發者對於 C++ 的發展頗大,都是核心級的人物,所以 Boost 想當然而,將會是 C++ 新一代的 Standard.目前已有10個 Boost Library 被收錄至 C++ Standard Library Technical Report (TR1),下一個階段將有更多程式庫被收錄至 TR2 內,然而發展成成熟的 C++ Standard Library 2.0.

為了體驗這個嶄新的標準,我就在我的電腦上裝上 Boost,利用 Visual Studio 2005 來搭配使用,(當然,你也可以使用其它常見的工具),其支援的 Compiler 如官網示 http://www.boost.org/more/getting_started.html#Tools

1. 先到Boost首頁,然後點取下載頁面

2. 下載 boost 以及 boost-jam 兩個套件:將 boost 解開放至某個目錄下(如 C:\ ),再將 boost-jam 裡頭的 bjam.exe 放至 boost 目錄中 (如 C:\boost_1_33_1 )

3. 開個 cmd 到 C:\boost_1_33_1,先將 VS8 的環境變數設定好(可以執行 C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat )

4. 最後執行 bjam -sTOOLS=vc-8_0 install 開始編譯,經過一段時間後,就把 Boost Library 編譯好了

5. 打開 VS8,把 include 目錄及 lib 目錄設定好,即可開始使用 Boost 所提供的便利

目前 Boost TR1 所提供的組件:
String and text processing
Containers
Iterators
Algorithms
Function Objects and higher-order programming
Generic Programming
Template Metaprogramming
Preprocessor Metaprogramming
Concurrent Programming
Math and numerics
Correctness and testing
Data structures
Input/Output
Inter-language support
Memory
Parsing
Programming Interfaces
Miscellaneous
Broken compiler workarounds