Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91127361
loops.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Nov 8, 04:47
Size
631 B
Mime Type
text/x-c
Expires
Sun, Nov 10, 04:47 (2 d)
Engine
blob
Format
Raw Data
Handle
22198791
Attached To
R7571 SP4E-TB-TL-FR
loops.cpp
View Options
#include <array>
#include <vector>
int main() {
std::vector<int> vec(10);
for (int i = 0; i < 10; ++i) {
vec[i] = 10;
}
std::array<int, 10> array;
for (int i = 0; i < 10; ++i) {
array[i] = 10;
}
{
// vector loop with iterators
std::vector<int>::iterator it = vec.begin();
std::vector<int>::iterator end = vec.end();
for (; it != end; ++it) {
*it = 10.;
}
}
{
// with the auto
auto it = vec.begin();
auto end = vec.end();
for (; it != end; ++it) {
*it = 10.;
}
}
{
// with the range loop
for (auto &v : vec) {
v = 10.;
}
}
}
Event Timeline
Log In to Comment