Doug Mika <
doug...@gmail.com> wrote in
news:76254bc0-615c-40f4...@googlegroups.com:
> Hi
>
> if I have an existing array of simple data types, and I use std::copy
> to create a copy of the array, the simple data types are simply copied
> into my second array? True/False?
You cannot create an array by std::copy. std::copy merely copies elements
from one place to another, so the destination array must be already
exisiting. Yes, it can grow a container like std::vector by using
std::back_inserter, but this won't work with a C or C++ array (which has
fixed size), and the destination container must still be created
beforehand.
But otherwise, you are right, std::copy indeed copies data (doh).
>
> if I have an existing array of my own user defined objects, and I use
> std::copy to create a copy of the array, each element of the array is
> copied using my objects copy constructor? True/False?
I guess it's more likely that the assignment operator gets used, unless
you are using std::back_inserter or something like that.
> if I have an existing array of pointers, and I use the std::copy
> function to create a copy of the array, is each pointer going to be
> merely copied, or is the object (to which the pointer points to) going
> to have it's copy constructor invoked?
Raw pointers belong to "simple data types", so as per your first point
they just get copied. Nothing more happens. If you want deep copying this
has to be arranged specially.
hth
Paavo