C++之boost::array的用法
更新時(shí)間:2014年10月22日 10:37:54 投稿:shichen2014
這篇文章主要介紹了C++之boost::array的用法,以實(shí)例的形式簡(jiǎn)單講述了靜態(tài)數(shù)組的容器boost::array的使用技巧,具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了C++之boost::array的用法,分享給大家供大家參考。具體如下:
復(fù)制代碼 代碼如下:
#include <string>
#include <iostream>
#include <boost/array.hpp>
#include <algorithm>
using namespace std;
int main()
{
boost::array<int, 5> array_temp = {{12, 8, 45, 23, 9}};
sort(array_temp.begin(), array_temp.end());
copy(array_temp.begin(), array_temp.end(), ostream_iterator<int>(cout, " "));
return 0;
}
#include <iostream>
#include <boost/array.hpp>
#include <algorithm>
using namespace std;
int main()
{
boost::array<int, 5> array_temp = {{12, 8, 45, 23, 9}};
sort(array_temp.begin(), array_temp.end());
copy(array_temp.begin(), array_temp.end(), ostream_iterator<int>(cout, " "));
return 0;
}
希望本文所述對(duì)大家的C++程序設(shè)計(jì)有所幫助。
相關(guān)文章
C++實(shí)現(xiàn)歸并排序(MergeSort)
這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)歸并排序,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-04-04
Linux?C/C++?timeout命令實(shí)現(xiàn)運(yùn)行具有時(shí)間限制功能
inux?timeout命令的一個(gè)屬性是時(shí)間限制。可以為任何命令設(shè)置時(shí)間限制。如果時(shí)間到期,命令將停止執(zhí)行,這篇文章主要介紹了Linux?C/C++?timeout命令實(shí)現(xiàn)(運(yùn)行具有時(shí)間限制),需要的朋友可以參考下2023-02-02
C++初始化數(shù)組的幾種常見方法(簡(jiǎn)單易懂)
本文介紹了C++中數(shù)組的初始化方法,包括一維數(shù)組和二維數(shù)組的初始化,以及用new動(dòng)態(tài)初始化數(shù)組,在C++11及以上版本中,還提供了使用std::array和std::vector進(jìn)行靜態(tài)和動(dòng)態(tài)初始化的方式,需要的朋友可以參考下2025-02-02

