mirror of
https://github.com/boostorg/array.git
synced 2025-07-12 12:16:32 +02:00
initial checkin of Nico's array library
[SVN r7678]
This commit is contained in:
57
array4.cpp.html
Normal file
57
array4.cpp.html
Normal file
@ -0,0 +1,57 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>array4.cpp</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
|
||||
|
||||
<TABLE HEIGHT=40 WIDTH="100%">
|
||||
<TR> <TD ALIGN=LEFT WIDTH="100%" BGCOLOR="#DDDDDD">
|
||||
<FONT face="Arial,Helvetica" size=+2><B>
|
||||
array4.cpp
|
||||
</B></FONT>
|
||||
</TD></TR></TABLE><BR>
|
||||
|
||||
<BR><BR>
|
||||
<TT>
|
||||
<SPAN class="Source">
|
||||
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >* example for using class array<></FONT></I><BR>
|
||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR>
|
||||
#include <algorithm><BR>
|
||||
#include <functional><BR>
|
||||
#include <string><BR>
|
||||
#include <iostream><BR>
|
||||
#include <<A href="./array.hpp.html">boost/array.hpp</A>><BR>
|
||||
<BR>
|
||||
int main()<BR>
|
||||
{<BR>
|
||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// array of arrays of seasons</FONT></I><BR>
|
||||
boost::array<boost::array<std::string,4>,2> seasons_i18n = {<BR>
|
||||
{ { { "spring", "summer", "autumn", "winter", } },<BR>
|
||||
{ { "Fruehling", "Sommer", "Herbst", "Winter" } }<BR>
|
||||
}<BR>
|
||||
};<BR>
|
||||
<BR>
|
||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// for any array of seasons print seasons</FONT></I><BR>
|
||||
for (unsigned i=0; i<seasons_i18n.size(); ++i) {<BR>
|
||||
boost::array<std::string,4> seasons = seasons_i18n[i];<BR>
|
||||
for (unsigned j=0; j<seasons.size(); ++j) {<BR>
|
||||
std::cout << seasons[j] << " ";<BR>
|
||||
}<BR>
|
||||
std::cout << std::endl;<BR>
|
||||
}<BR>
|
||||
<BR>
|
||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// print first element of first array</FONT></I><BR>
|
||||
std::cout << "first element of first array: "<BR>
|
||||
<< seasons_i18n[0][0] << std::endl;<BR>
|
||||
<BR>
|
||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// print last element of last array</FONT></I><BR>
|
||||
std::cout << "last element of last array: "<BR>
|
||||
<< seasons_i18n[seasons_i18n.size()-1][seasons_i18n[0].size()-1]<BR>
|
||||
<< std::endl;<BR>
|
||||
}<BR>
|
||||
<BR>
|
||||
</SPAN>
|
||||
</TT>
|
||||
</BODY>
|
||||
</HTML>
|
Reference in New Issue
Block a user