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

  • SEARCH
  • Home
  • 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 8911375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:55:39+00:00 2026-06-15T03:55:39+00:00

struct vec3{ vec3(){x=y=z=0.0f;}; float x,y,z; }; vec3 array[10]; char buffer[100]; memcpy(buffer, array, sizeof(array)); memcpy(array,

  • 0
struct vec3{
vec3(){x=y=z=0.0f;};
float x,y,z;
};

vec3 array[10];
char buffer[100];
memcpy(buffer, array, sizeof(array));
memcpy(array, buffer, sizeof(array));

struct Vec3 is not Plain Old Datatype (POD type).
Is it this code correct and/or is it exist some garantees about memory layout in C++2003?

  • 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-06-15T03:55:41+00:00Added an answer on June 15, 2026 at 3:55 am

    Not in C++03, but in C++11 this is fine.

    They introduced a concept called standard-layout, which is really what POD should have been. I won’t go into the standardese, but the new category is the recognition that your class is really just a POD with a new way of initializing it; the layout is still the same, hence the name “standard layout”.

    So most (all?) of those things that used to be POD only are now standard-layout only, so you’re good to go.

    In practice this works fine in C++03 compilers; you can view this as them supporting C++11 in some way.

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

Sidebar

Related Questions

I have a struct that's defined like this: struct Vec3 { float x, y,
I can do this in c++/g++: struct vec3 { union { struct { float
struct DummyStruct{ unsigned long long std; int type; }; DummyStruct d; d.std = 100;
Let's say I have defined an array float floatBuffer[4] and I have a struct:
struct { char a; int b; } x; Why would one define a struct
struct elem { int i; char k; }; elem user; // compile error! struct
struct match { char men[64]; char women[64]; char menNum[1000]; char woNum[1000]; }; void printOut();
struct dataStruct { const char* s; int num; }; struct Final_struct { int n;
Suppose I have: struct Vec3 { double x; double y; double z; } ;
struct Vector { float i,j,k; } std::vector pt[size]; ... = ... + pt[temp]; temp

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.