Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Compiler optimi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 44206 of 47925
Post > Topic >>

Compiler optimizations of copying PODs

by tommy.hinks@[EMAIL PROTECTED] Mar 29, 2008 at 04:32 PM

I am wondering if anyone knows how compilers auto-generate copy
constructors for PODs. Let me explain what I mean with an example:

struct A
{
int u;
int v;
};

If I were to write the copy constructor for the POD myself, I would
write it like this:

A::A(const A rhs)
: u(rhs.u), v(rhs.v) {}

the main point being that the member variables are initialized upon
creation, and not created and then assigned a value, like this:

A::A(const A rhs)
{
u = rhs.u;
v = rhs.v;
}

Or perhaps some other form of bitwise (shallow) copying is done by the
compiler for auto-generated PODs?

Any thoughs on this?

Thanks,

T
 




 3 Posts in Topic:
Compiler optimizations of copying PODs
tommy.hinks@[EMAIL PROTEC  2008-03-29 16:32:53 
Re: Compiler optimizations of copying PODs
Kai-Uwe Bux <jkherciue  2008-03-29 19:52:06 
Re: Compiler optimizations of copying PODs
Andrey Tarasevich <and  2008-03-30 09:17:15 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 6 17:36:38 CDT 2008.