Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4122926
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:32:43+00:00 2026-05-20T23:32:43+00:00

In another question I incorrectly used the term POD to refer to data types

  • 0

In another question I incorrectly used the term POD to refer to data types that aren’t actually POD types (on account of having a constructor). Now, I’ve looked through the standard and couldn’t find a proper name for what I want. Nor can I actually find a guarantee that copying is actually allowed.

The data type I mean is a POD, but may contain functions, including constructors, but nothing that should alter its alignment or size characteristics when compared to an equivalent POD type.

In section 3.9 of the standard it states that POD data can be copied with memcpy, either to another object, or to character data and back. No such guarantee is ever made of non-POD data.

However, the object representation of an object is defined in the same section. It is defined such that one would believe any two objects of the same type could be safely copied via memcpy.

So my questions are:

  1. Is the copy with memcpy actually guaranteed to be safe for such objects?
  2. If yes, then why is there a special note about memcpy and POD?
  3. Is there a name for this type of data which is memcpy safe?

A simple example of the type of object I mean:

struct ex_struct
{
  int a,b,c,d;
  ex_struct() : a(123) { }
}

Reading the C++0x draft, my struct would appear to be a trivially copyable class (9.1). I believe that implies memcpy would be safe.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:32:44+00:00Added an answer on May 20, 2026 at 11:32 pm

    In C++0x, the concept of PODness is broken out into several individually useful categories:

    A trivially copyable class is a class that (draft 3242, section [class]):

    • has no non-trivial copy constructors (12.8),
    • has no non-trivial move constructors (12.8),
    • has no non-trivial copy assignment operators (13.5.3, 12.8),
    • has no non-trivial move assignment operators (13.5.3, 12.8), and
    • has a trivial destructor (12.4).

    A trivial class is a class that has a trivial default constructor (12.1) and is trivially copyable.

    [ Note: In particular, a trivially copyable or trivial class does not have virtual functions or virtual base
    classes. — end note ]

    A standard-layout class is a class that:

    • has no non-static data members of type non-standard-layout class (or array of such types) or reference,
    • has no virtual functions (10.3) and no virtual base classes (10.1),
    • has the same access control (Clause 11) for all non-static data members,
    • has no non-standard-layout base classes,
    • either has no non-static data members in the most derived class and at most one base class with
      non-static data members, or has no base classes with non-static data members, and
    • has no base classes of the same type as the first non-static data member.

    The requirements for trivial constructors, assignment operators, and destructor are scattered throughout section 12 “Special Member Functions” [special].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In another question , a user pointed out that the new keyword was dangerous
Edit: From another question I provided an answer that has links to a lot
Another question asked about determining odd/evenness in C, and the idiomatic (x & 1)
In another question I posted yesterday, I got very good advice on how a
In another question, Mark speaks highly of IDEs, saying some people still just dont
In another question on SO I answered with code like the one below and
In another question, the accepted answer shows a method for reading the contents of
This question is based on another question of mine (thankfully answered). So if in
This question is related to another question which I asked yesterday! List all links
Inspired by another question asking about the missing Zip function: Why is there no

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.