在Windows和Visual Studio上安裝Boost
1,在boost的網(wǎng)站上下載一個boost的Windows版本的安裝器。
http://www.boost-consulting.com/download/windows
這個程序會自動下載和安裝boost。
整個Boost有接近
2,或者你也可以直接在boost網(wǎng)站上下載完整版的boost,下載以后安裝。
建議你使用第一種方式下載。因為那個程序的下載速度非??臁N疫x擇的是從日本下載。
需要在項目屬性中附加boost的目錄。
我選擇的安裝Boost的目錄如下:
D:/C++Runtim/boost/boost_1_34_1/
1,在“附加包含目錄”中添加對boost頭文件目錄的包含。以便正確include boost的頭文件。
對于我的配置來說,這里需要輸入D:/C++Runtim/boost/boost_1_34_1/。
這個目錄下面包含了頭文件:
2,還需要附加boost的lib和dll文件
在“附加庫目錄”中包括boost的lib庫目錄文件夾。
對于我的配置來說,這里需要輸入D:/C++Runtim/boost/boost_1_34_1/lib
現(xiàn)在,可以編寫我們的第一個boost程序了。
#include "stdafx.h"
#include <iostream>
#include <cassert>
#include <string>
#include "boost/regex.hpp"
int main() {
// 3 digits, a word, any character, 2 digits or "N/A",
// a space, then the first word again
boost::regex reg("http://d{3}([a-zA-Z]+).(//d{2}|N/A)//s//1");
std::string correct="123Hello N/A Hello";
std::string incorrect="123Hello 12 hello";
assert(boost::regex_match(correct,reg)==true);
assert(boost::regex_match(incorrect,reg)==false);
}