天天看點

BOOST庫array使用 類似std庫的vector

BOOST庫的array,  類似std庫的vector.

下圖所示書籍的下載下傳位址,我的另一篇部落格内有記載:

 https://www.cnblogs.com/happybirthdaytoyou/p/13837384.html 

BOOST庫array使用 類似std庫的vector
 實驗代碼:

#include <boost/array.hpp>
#include <iostream>
#include <string>
#include <algorithm>

int main(void){

     typedef boost::array<std::string, 3> array; 
     array a; 
     a[0] = "Boris"; 
     a.at(1) = "Anton"; 
     *a.rbegin() = "Caesar"; 

     std::sort(a.begin(), a.end());

     for(array::const_iterator it = a.begin(); it != a.end(); ++it)
    std::cout << *it << std::endl; 

     std::cout << a.size() << std::endl; 
     std::cout << a.max_size() << std::endl;

    return 0;
}      

 makefile:

.PHONY: DOIT

DOIT:
    mips-linux-gnu-g++ -I..  my_boost_test.cpp -L../lib  -lboost_thread -lboost_system -o cpp_hello.out  -lrt -lpthread      

.

/************* 社會的有色眼光是:博士生、研究所學生、大學生、工廠中的房間勞工; 重點大學高材生、普通院校、二流院校、野雞大學; 年薪百萬、五十萬、五萬; 這些都隻是帽子,可以失敗千百次,但我和社會都覺得,人隻要成功一次,就能換一頂帽子,隻是社會看不見你之前的失敗的帽子。 當然,換帽子決不是最終目的,走好自己的路就行。 杭州.大話西遊 *******/

繼續閱讀