BOOST库array使用 类似std库的vector

BOOST库的array,  类似std库的vector.

下图所示书籍的下载地址,我的另一篇博客内有记载:

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

 

 实验代码:

#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

 

 

 

 

 

.

/************* 社会的有色眼光是:博士生、研究生、本科生、车间工人; 重点大学高材生、普通院校、二流院校、野鸡大学; 年薪百万、五十万、五万; 这些都只是帽子,可以失败千百次,但我和社会都觉得,人只要成功一次,就能换一顶帽子,只是社会看不见你之前的失败的帽子。 当然,换帽子决不是最终目的,走好自己的路就行。 杭州.大话西游 *******/
原文地址:https://www.cnblogs.com/happybirthdaytoyou/p/13837654.html