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="James Kanze, post: 2934098"] Actually, the standard has a definition for "an identical class". It's called the "one definition rule". But I rather doubt that this is what JohnQ is talking about. (Of course, I'm not too sure what he's talking about. He seems to avoid precise vocabulary intentionally, just to create confusion.) Anyway, someone else has already posted the definition of POD, which is about the only real categorization which is recognized by the standard. (And I know you know that.) The standard doesn't talk about "pseudo-destructors". What I think you're getting at is that you can call the destructor for any type, e.g. something like p->~int() is legal. (Obviously, no one does this directly. But a lot of template code results in it, and in pre-template days, it ended up generated by <generic.h> just about any time you wrote a container class.) Explicitly calling the destructor on a type such as int, which doesn't have a destructor, is a no-op. A second point to keep in mind is that a class type (i.e. any type defined by means of the keywords class, struct or union) always has a destructor. If you don't provide one, the compiler does. However, a "trivial destructor" doesn't prevent the type from being a POD. The standard also defines very rigorously when a destructor is trivial; a user defined destructor is never trivial (but the compiler generated one is not always trivial either). According to the standard, the semantic is always member-wise copy. As you know, of course, the compiler can do anything it wishes as long as the observable behavoir of the program is "as if" memberwise copy took place. In practice, there are probably a lot of classes (not even always POD's) in which the compiler will effectively generate the equivalent of a memcpy, because it can determine that doing so, instead of literally doing a memberwise copy, will not result in any difference in the observable behavior. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Default ctor, etc generated by compiler for structs?
Top