473,412 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

What exactly is a POD type

I searched the standard for an exact explanation of what "plain old
data" might be... I suppose, built-in types are POD. But what about this:

struct Data {
int a,b;
};

Is Data a POD type?

--
Regards,
Matthias
Jul 23 '05 #1
10 1643
Matthias wrote:
I searched the standard for an exact explanation of what "plain old
data" might be... I suppose, built-in types are POD. But what about this:

struct Data {
int a,b;
};

Is Data a POD type?
...


Yes.

The definition of POD type is given in 3.9/10 and is partially based on
definition of "POD-class" given in 9/4, which is in turn based on the
definition of "aggregate" given in 8.5.1/1.

--
Best regards,
Andrey Tarasevich

Jul 23 '05 #2
"Matthias" <no****@digitalraid.com> wrote in message
news:cv*************@news.t-online.com
I searched the standard for an exact explanation of what "plain old
data" might be... I suppose, built-in types are POD. But what about
this:

struct Data {
int a,b;
};

Is Data a POD type?

Yes. See the C++ FAQ:

http://www.parashift.com/c++-faq-lit....html#faq-26.7
--
John Carson
Jul 23 '05 #3
John Carson wrote:
"Matthias" <no****@digitalraid.com> wrote in message
news:cv*************@news.t-online.com
I searched the standard for an exact explanation of what "plain old
data" might be... I suppose, built-in types are POD. But what about
this:
struct Data {
int a,b;
};

Is Data a POD type?


Yes. See the C++ FAQ:

http://www.parashift.com/c++-faq-lit....html#faq-26.7


The FAQ mention that POD types must not have constructors or a
destructor. I guess they mean /user defined/ ctor/dtor? Because the Data
struct above has a compiler generated ctor/dtor right? This would by
definition of the FAQ make it a non-POD type.

--
Regards,
Matthias
Jul 23 '05 #4
Andrey Tarasevich wrote:
struct Data {
int a,b;
};

Is Data a POD type?
...

Yes.


Another question...
Why offsetof macro may not work with non POD types?
And why pointer to members should?

--
fabioppp
Jul 23 '05 #5
Matthias wrote:
The FAQ mention that POD types must not have constructors or a
destructor. I guess they mean /user defined/ ctor/dtor?

Yes.


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #6
fabioppp wrote:
Another question...
Why offsetof macro may not work with non POD types?
And why pointer to members should?

....because the standard says so.

Poitner to members aren't just an offset by the way. They
have to work on polymorphic objects and hence need additional
information.
Jul 23 '05 #7
Matthias wrote:
I searched the standard for an exact explanation of what "plain old
data" might be... I suppose, built-in types are POD. But what about this:

struct Data {
int a,b;
};

Is Data a POD type?


No.

Plain Old Data refers to built-in data types -- intrgral types:
signed and unsigned char, short int, int, long int, long long int
and floating-point types float, double and long double.

Jul 23 '05 #8
E. Robert Tisdale wrote:
...
I searched the standard for an exact explanation of what "plain old
data" might be... I suppose, built-in types are POD. But what about this:

struct Data {
int a,b;
};

Is Data a POD type?


No.

Plain Old Data refers to built-in data types -- intrgral types:
signed and unsigned char, short int, int, long int, long long int
and floating-point types float, double and long double.
...


Wrong. The types you mention are referred to as arithmetic types. All
arithmetic types are POD, but not all POD types are arithmetic.

The above struct is a POD-class, which makes it a POD type.

--
Best regards,
Andrey Tarasevich

Jul 23 '05 #9
Ron Natalie wrote:
Poitner to members aren't just an offset by the way. They
have to work on polymorphic objects and hence need additional
information.


The only problem I can figure out is multiple inheritance,
where the offset of a field has to be added with some other value.
With static offset there is no way to achieve this, while pointer to
member (because of the heaviest typing) can achieve this.

Jul 23 '05 #10
fabioppp wrote:
Ron Natalie wrote:
Poitner to members aren't just an offset by the way. They
have to work on polymorphic objects and hence need additional
information.

The only problem I can figure out is multiple inheritance,
where the offset of a field has to be added with some other value.
With static offset there is no way to achieve this, while pointer to
member (because of the heaviest typing) can achieve this.

In practice, that is the problem (virutal inheritance adds yet another
wrinkle).

I believe that at some point in setting down the rules, someone had
the idea that some kind of runtime access control might be useful and
hence put restrictions on things (offsetof, member ordering) that
relax the concept that classes are contiguous accross access specifiers.
Jul 23 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark Constant | last post by:
All I want to do is have a xml file like this <Entertainment> <Movie> <Title>(Title Here)</Title> <Rating>(Rating Here)</Title> </Movie> <Movie> <Title>(Title Here)</Title> <Rating>(Rating...
20
by: Wayne Sutton | last post by:
OK, I'm a newbie... I'm trying to learn Python & have had fun with it so far. But I'm having trouble following the many code examples with the object "self." Can someone explain this usage in...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
17
by: candy_init | last post by:
I sometimes comes across statements which invloves the use of size_t.But I dont know exactly that what is the meaning of size_t.What I know about it is that it is used to hide the platform...
19
by: Fernando Cacciola | last post by:
I'm puzzled, Why and how _exactly_ is this: void Foo<T>(T v ) where T : Interface/Value/Class/class any better than this void Foo( Interface/Value/Class/object v )
5
by: Martin Jřrgensen | last post by:
Hi, Consider this code: --- beginning of code --- #include <iostream> using namespace std; class Child{ public:
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
132
by: Frederick Gotham | last post by:
If we look at a programming language such as C++: When an updated Standard comes out, everyone adopts it and abandons the previous one. It seems though that things aren't so clear-cut in the C...
18
by: cj | last post by:
members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe. I'm under the impression before you can use a class you have to make an...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.