Time of Update: 2018-12-04
函數的部分原型template<typename SequenceT, typename PredicateT> void trim_if(SequenceT & Input, PredicateT IsSpace);template<typename OutputIteratorT, typename RangeT, typename PredicateT> OutputIteratorT trim_copy_if(OutputIteratorT
Time of Update: 2018-12-04
erase的主要函數(以及其包括的copy函數)包括: erase_range, erase_first, erase_last, erase_nth, erase_head, erase_tail, erase_regex, erase_all, erase_all_regexvoid test_string_erase(){using namespace boost;std::string str = "Hello Dolly, Hello World!";std::cout
Time of Update: 2018-12-04
大家都希望可以像操作STL容器一樣的去運算元組,C++可沒有提供這個東西,有時候你會選擇使用vector來替代,不過這畢竟不是個好的辦法,畢竟vector類比動態數組比較穩妥,而用它去替代一個普通的數組,開銷畢竟太大了。而恰好,boost::array就為你提供了這個功能。1. 這樣的集合體有如下特點: (1)無使用者聲明的建構函式。(2)無私人的或保護的非待用資料成員。(3)無基類。(4)無虛擬函數。boost::array的定義如下(簡化):template<class T,
Time of Update: 2018-12-04
boost::noncopyable比較簡單, 主要用於單例的情況.通常情況下, 要寫一個單例類就要在類的聲明把它們的建構函式, 賦值函數, 解構函式, 複製建構函式隱藏到private或者protected之中, 每個類都這麼做麻煩.有noncopyable類, 只要讓單例類直接繼承noncopyable. class
Time of Update: 2018-12-04
replace的主要函數(以及其包括的copy函數)包括:replace_range, replace_first, replace_last, replace_nth, replace_head, replace_tail, replace_regex, replace_all, replace_all_regexvoid test_string_replace(){using namespace boost;std::string str = "Hello Dolly, Hello
Time of Update: 2018-12-04
// operator+=// 優點: 可應用與stl中定義的標準容器(vector, list, set, map等)// 缺點: 對於其他類型的容器(如boost新容器)則無能為力void test_assign_plus(){using namespace boost::assign;// 1. vectorstd::vector<int> values;values += 1, 2, 3, 4, 5, 6, 7, 8, 9; // 插入值到容器的末尾BOOST_ASSERT(
Time of Update: 2018-12-04
template<typename SequenceSequenceT, typename Range1T> range_value< SequenceSequenceT >::type join(const SequenceSequenceT & Input, const Range1T & Separator);template<typename SequenceSequenceT, typename Range1T, typename
Time of Update: 2018-12-04
POCO的優點: 1) 比boost更好的線程庫,特別是一個活動的方法的實現,並且還可設定線程的優先順序。 2) 比 boost:asio更全面的網路程式庫。但是boost:asio也是一個非常好的網路程式庫。 3) 包含了一些Boost所不包含的功能,像XML,資料庫介面等。 4) 跟Boost相比,整合度更高,是更加統一的一個庫。 5) Poco的c++代碼更清潔,現代和易理解。對不是模板編程專家的人來說,POCO的代碼比大多數Boost庫容易理解得多 6) 可以在許多平台上使用
Time of Update: 2018-12-04
1. 概述包含的標頭檔: #include <boost/date_time/posix_time/posix_time.hpp>通常的命名空間: using namespace boost::posix_time;2. 建構函式跟date的建構函式一樣, 都基本建構函式, 字串構造, clock構造. ptime還可以通過轉換函式構造.void test_ptime_construct(){using namespace boost::gregorian;using
Time of Update: 2018-12-04
time_duration的例子void test_ptime_duration(){using namespace boost::posix_time;using namespace boost::gregorian;// time_duration構造的常用方法time_duration td1(1, 2, 3, 4);time_duration td2 = time_duration(1, 2, 3) + milliseconds(4) +
Time of Update: 2018-12-04
RAD Studio XE2 v16.0.4265.43595 官方 ISO 檔案下載(2.33GB):http://altd.embarcadero.com/download/radstudio/xe2/delphicbuilder_xe2_win_dl.isoRAD Studio XE2 v16.0.4276.44006 (With Update 1) 官方 ISO 檔案下載(2.33GB):http://altd.embarcadero.com/download/radstudio/xe2
Time of Update: 2018-12-04
一、概論1、序列式容器array(build-in) C++內建vectorheap 內含一個vectorpriority-queue 內含一個heaplistslistdequestack 內含一個dequequeue 內含一個deque2、關聯式容器RB-treeset 內含一個RB-treemap 內含一個RB-treemultiset 內含一個RB-treemultimap 內含一個RB-treehashtablehash_set 內含一個hashtablehash_map
Time of Update: 2018-12-04
ptr_fun是將一個普通的函數適配成一個仿函數(functor), 添加上argument_type和result type等類型,它的定義如下:template<class _Arg1, class _Arg2, class _Result> inline pointer_to_binary_function<_Arg1, _Arg2, _Result, _Result(__clrcall *)(_Arg1, _Arg2)>
Time of Update: 2018-12-04
void myfun1(int& i){std::cout << i << " ";}void myfun2(int i, const char* prefix){std::cout << prefix << i << std::endl;}struct mystruct1 {void operator() (int& i){std::cout << i << " ";}}
Time of Update: 2018-12-04
函式宣告:template<typename Range1T, typename Range2T> iterator_range find_first(Range1T & Input, const Range2T & Search);template<typename Range1T, typename Range2T> iterator_range find_last(Range1T & Input, const Range2T &
Time of Update: 2018-12-04
如果使用months,當日期是28號-31號時增減月份,可能會導致問題。可以使用month_iterator可以解決這個問題。詳見下面的例子。void test_month_iterator(){using namespace boost::gregorian;date d(2010, 11, 29);d += months(1);assert(d == date(2010, 12, 29));d += months(1);assert(d == date(2011, 1, 29));d +=
Time of Update: 2018-12-04
1. disable, once, error#pragma warning(disable: 4507 34; once: 4385; error: 164)等價於:#pragma warning(disable:4507 34) // 不顯示4507和34號警告資訊#pragma warning(once:4385) // 4385號警告資訊僅報告一次#pragma warning(error:164) // 把164號警告資訊作為一個錯誤。2. push, pop同時這個pragma
Time of Update: 2018-12-04
date_duration與date_period以前沒有特別關注, 常混淆.date_duration: 日期差(日期間隔)date_period: 日期段通過下面的例子可以更好的理解:void test_date_duration(){using namespace boost::gregorian;// 常見的幾種構造方法{date_duration dd(3);days dd1(neg_infin);days dd2(pos_infin);days
Time of Update: 2018-12-04
多日生病,部落格無法更新。補之。Finder是一個搜尋某個容器的任意部分的仿函數,一般無法單獨使用。搜尋的結果以一個限定所選擇的部分的iterator_range的形式給出。常用於函數find, find_format, find_format_copy, find_format_all, find_format_all_copyfind_iterator的Factory 方法: make_find_iterator, make_split_iteratorfind_iterator的建構函式:
Time of Update: 2018-12-04
1.標頭檔#include <ios>2.使用說明讓流將bool解析成為單詞true, false.void test_boolalpha(){std::cout << "true is " << true << std::endl;std::cout << "false is " << false << std::endl;// 運行下面這個語句, 在輸出資料流中的bool值將發生變化std::cout