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++
c++0x pods and constructors
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="Johannes Schaub (litb), post: 3967087"] Aggregates but not PODs, both in C++03 and C++0x: string foo[10]; struct bar { string baz; }; In C++0x, you can use memcpy on trivially copyable types. POD is too strict a requirement for this - so if you just want to use memcpy on a type for example, making a type trivially copyable would suffice, in particular: - has no non-trivial copy constructors (12.8), — has no non-trivial copy assignment operators (13.5.3, 12.8), and — has a trivial destructor (12.4). A trivial class then is a class that is trivially copyable and that has a trivial default constructor. F is trivial and G is trivially copyable: struct F { Foo() = default; F(int a):a(a) { } int a; }; struct G { Foo(int a):a(a) { } int a; }; For other things, a class has to be a standard layout class. Thus is true for "offsetof", to inspect a common initial sequence when two such structs are in an union, etc. Look up the details in the latest draft at 9/6. A POD is a class is trivial and a standard layout class and has no members of non-POD etc... . Actually, i haven't found something in the c++0x language in 2960 that still requires things to be PODs. Things either seem to refer to standard layout classes or trivially copyable. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
c++0x pods and constructors
Top