日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > c/c++ >内容正文

c/c++

[C++]VS2005(VC8) 使用 Boost

發(fā)布時(shí)間:2023/12/6 c/c++ 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [C++]VS2005(VC8) 使用 Boost 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
測(cè)試環(huán)境:
[1] Widnows XP Professional
[2] Visual Studio 2005 Team Studio(VC8.0)
[3] WinCvs 1.3

1. 下載 Boost
  • ? 透過(guò) CVS 下載最新版
    ? cvs -d:pserver:anonymous@boost.cvs.sourceforge.net:/cvsroot/boost login
    [詢(xún)問(wèn)密碼時(shí),直接輸入 Enter 略過(guò)]
    cvs -z3 -d:pserver:anonymous@boost.cvs.sourceforge.net:/cvsroot/boost checkout boost
    cvs -d:pserver:anonymous@boost.cvs.sourceforge.net:/cvsroot/boost logout


2. 組態(tài)設(shè)定
  • 執(zhí)行 C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat

3. 建置與安裝(* [boost] 表示 boost 的根目錄)
  • ? 執(zhí)行 [boost]\tools\jam\build_dist.bat
  • ? 將 [boost]\tools\jam\src\boost-jam-3.1.14-1-ntx86\bjam.exe 複製到 [boost]\bjam.exe
  • ? 切換到 [boost]\ 執(zhí)行 bjam "-sTOOLS=vc-8_0" install
  • ? 漫長(zhǎng)的等待~~~~~~~~ 相關(guān) header 與 lib 產(chǎn)生在 C:\Boost
  • ?修改 C:\Boost\include\boost-1_35\boost\config\suffix.hpp 內(nèi)容
    #? define BOOST_LIB_TOOLSET "vc80"
    成如下
    #? define BOOST_LIB_TOOLSET "vc"
    (或是將 c:\Boost\Lib\ 下的所有 *.lib 的 -vc- 取代為 -vc80- (如:bgl-viz-vc.lib -> bgl-viz-vc80.lib, boost_date_time-vc-1_35.dll -> boost_date_time-vc80-1_35.dll)否則程式在連結(jié)時(shí)會(huì)發(fā)生找不到 lib 的錯(cuò)誤)
  • 將 C:\Boost\include\boost-1_35 加入 VC2005 的 Include 路徑
    • Tools | Options | Projects and Solutions | VC++ Directories
    • Show directories for: Include files
  • 將 C:\Boost\lib 加入 VC2005 的 Lib 路徑
    • Tools | Options | Projects and Solutions | VC++ Directories
    • Show directories for: Library files

4. 測(cè)試

//?正規(guī)表示法測(cè)試:信用卡號(hào)檢測(cè)
#include?<boost/regex.hpp>
#include?<iostream>

bool?validate_card_format(const?std::string?s)
{
????????static?const?boost::regex?e("(\\d{4}[-?]){3}\\d{4}");
????????return?regex_match(s,?e);
}

int?_tmain(int?argc,?_TCHAR*?argv[])
{
????std::cout?<<?(validate_card_format("1111-1111-1111-2222")?"PASS":"Error")?;?//?PASS

????return?0;
}
//?計(jì)算兩個(gè)日期相差的天數(shù)
#include?<iostream>
#include?<boost/date_time/gregorian/gregorian.hpp>

using?namespace?std;
using?namespace?boost::gregorian;

int?_tmain(int?argc,?_TCHAR*?argv[]){
????date_duration?dd?=?date(2000,?1,?1)?-?date(1900,?1,?1);
????cout?<<?"The?twentieth?century?had?"?<<?dd.days()?<<?"?days"?<<?endl;?//?36524

????dd?=?date(2100,?1,?1)?-?date(2000,?1,?1);
????cout?<<?"The?twenty-first?century?will?have?"?<<?dd.days()?<<?"?days"?<<?endl;?//?36525???
?
????return?0;
}

總結(jié)

以上是生活随笔為你收集整理的[C++]VS2005(VC8) 使用 Boost的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。