Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120687277
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
Sun, Jul 6, 07:44
Size
631 B
Mime Type
text/x-c
Expires
Tue, Jul 8, 07:44 (2 d)
Engine
blob
Format
Raw Data
Handle
27229970
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