|
-
February 14th, 2003, 07:06 AM
#1
Question about uninitialized memory.
Hi, everyone!
My STL tutorial said,
--------
A raw_storage_iterator enables algorithms to
store results into uninitialized memory.
--------
But I do not know what means uninitialized memory.
Who can give me an explanation of what means
uninitialized memory? Here are two examples given
by the tutorial. Please give me the explanation through
the following examples.
Example 1:
--------
vector<int> a (2, 5);
vector<int> b (2, 7);
int *c = allocate((ptrdiff_t) a.size(), (int*)0 );
transform (a.begin(), a.end(), b.begin(),
raw_storage_iterator<int*, int> (c), plus<int>() );
copy (&c[0], &c[2], ostream_iterator<int> (cout, " ") );
--------
Example 2:
--------
template <class T1, class T2>
inline void construct(T1* p, const T2& value) {
new (p) T1(value);
}
int a[10] = {1, 2, 3, 4, 5};
copy (&a[0], &a[5], raw_storage_iterator<int*, int> (&a[5]) );
--------
Thanks in advance,
George
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|