mirror of
https://github.com/boostorg/array.git
synced 2025-06-30 14:31:06 +02:00
update from Nico
[SVN r10918]
This commit is contained in:
11
array2.cpp
11
array2.cpp
@ -12,23 +12,24 @@ int main()
|
||||
// create and initialize array
|
||||
array<int,10> a = { { 1, 2, 3, 4, 5 } };
|
||||
|
||||
PRINT_ELEMENTS(a);
|
||||
print_elements(a);
|
||||
|
||||
// modify elements directly
|
||||
for (unsigned i=0; i<a.size(); ++i) {
|
||||
++a[i];
|
||||
}
|
||||
PRINT_ELEMENTS(a);
|
||||
print_elements(a);
|
||||
|
||||
// change order using an STL algorithm
|
||||
reverse(a.begin(),a.end());
|
||||
PRINT_ELEMENTS(a);
|
||||
print_elements(a);
|
||||
|
||||
// negate elements using STL framework
|
||||
transform(a.begin(),a.end(), // source
|
||||
a.begin(), // destination
|
||||
negate<int>()); // operation
|
||||
PRINT_ELEMENTS(a);
|
||||
return 0;
|
||||
print_elements(a);
|
||||
|
||||
return 0; // makes Visual-C++ compiler happy
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user