|
-
May 30th, 2011, 03:33 PM
#22
Re: sizeof() class with empty base class
Paul I appreciate your answers, but why the pedantic need to point out the stupidities of programmers in years past? That std::string example is at the very least mildly insulting.
I know I'm new on this forum. So some slight background info is probably necessary. I have not been a C programmer in practice. I started with Pascal then moved directly to C++ and have been programming professionally since 1997. And please don't go into, "oh if you had programmed C, you would understand C++ better."
I intended this post to be more technical than "hey guys my program no compile, why no compile? What does stdio stand for? Visual Studio?"
Anyway. #pragma pack still works on non-POD. Just because a construct is C++, OO, derived, with virtuals, etc... doesn't mean you shouldn't care about data layout. If I want to allocate 256 of my Matrix4x4, I care that GCC is making me waste 1KB. My original intent with the example was to make a POD structure with the convenience of an empty base, which is invoking an interesting rule in C++, that even our beloved VisualC++ is not respecting. Maybe the MS programmers thought otherwise when it came to that rule.
I'm going to accomplish what I want without the derivation. And even use C-style containment when I need actual base data, to avoid the pitfalls of a vague standard and various compilers. I may even switch to C to feel even more pure.
Thanks for your 23K+ posts.
Are you on the east coast? Let's get together for an in-depth conversation about the usefulness of template meta-programming over some beer.
Regards.
-Amilcar
Last edited by chopin952; May 30th, 2011 at 03:39 PM.
Reason: Some typos.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|