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

 

 

 

 

 

 

.

posted @ 2020-10-18 22:45  一匹夫  阅读(369)  评论(0编辑  收藏  举报