Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Default ctor, etc generated by compiler for structs?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Bo Persson, post: 2933849"] JohnQ wrote: ::: Perhaps, but it's not defined in C++. Of more direct relevance to ::: the OP though is that, regardless of whether we're all happy with ::: that definition of "bitwise copy", it's not what happens in the ::: implicitly- defined copy constructor, which does a memberwise ::: copy. :: :: That's interesting. Apparently "a struct is a struct" hardly ever! :: Oh wait, does C do memberwise copy of structs also or bitwise? In C there is not much of a difference! Here's something else: In C and C++, the *compiler* is allowed to do a bitwise copy whenever it knows that it will work (and is better in some way). This means that the compiler generated copy constructor and assignment operator might look like a memcpy (or better!), even for a non-POD class. It is just you, the programmer, that cannot do this, because there are no guarantees in the standard that it will work always. The compiler knows all the special cases, and is allowed to take advantage of this knowledge. Bo Persson [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Default ctor, etc generated by compiler for structs?
Top