Hello,
if i write code like this:
#include <vector>
int main()
{
float big[] =
{
1.0f, 2.0f, 3.0f
};
std::vector<float> v(big, big + sizeof(big) / sizeof(big[0]));
}
are the floats twice in memory (one time from the literals, one time as
copies in the vector)? do compilers free initialisation memory after
initialization?
thanks for your short answer,
chris
|
|
0
|
|
|
|
Reply
|
4one (114)
|
6/12/2012 5:40:17 AM |
|
On 6/12/2012 1:40 AM, Chris Forone wrote:
> if i write code like this:
>
> #include <vector>
>
> int main()
> {
> float big[] =
> {
> 1.0f, 2.0f, 3.0f
> };
>
> std::vector<float> v(big, big + sizeof(big) / sizeof(big[0]));
> }
>
> are the floats twice in memory (one time from the literals, one time as
> copies in the vector)? do compilers free initialisation memory after
> initialization?
Most likely. Unless it isn't so.
Those are implementation details. If you need to know what any specific
compiler/library combination produces, look at the assembly code.
V
--
I do not respond to top-posted replies, please don't ask
|
|
0
|
|
|
|
Reply
|
v.bazarov (790)
|
6/12/2012 11:55:06 AM
|
|