Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

endian_buffer is not a POD in C++03 #27

Closed
viboes opened this issue Feb 11, 2018 · 2 comments
Closed

endian_buffer is not a POD in C++03 #27

viboes opened this issue Feb 11, 2018 · 2 comments

Comments

@viboes
Copy link

viboes commented Feb 11, 2018

Even when we define

#define BOOST_ENDIAN_FORCE_PODNESS
#define  BOOST_ENDIAN_NO_CTORS

endian_buffer is not a POD, because it uses a protected data member.

See https://wandbox.org/permlink/PSYwP0oCoJ9cNtkV

Defining it as public in C++03 solves the issue.

std::is_pod works in C++11 as the definition was relaxed.
The problem is that boost::is_pod is based on C++03 definition of POD.

Formal definition from the C++ standard (C++03 8.5.1 §1):

An aggregate is an array or a class (clause 9) with no user-declared constructors (12.1), no private or protected non-static data members (clause 11), no base classes (clause 10), and no virtual functions (10.3).

Formal definition from the C++ standard (C++03 9 §4):

A POD-struct is an aggregate class that has no non-static data members of type non-POD-struct, non-POD-union (or array of such types) or reference, and has no user-defined copy assignment operator and no user-defined destructor. Similarly, a POD-union is an aggregate union that has no non-static data members of type non-POD-struct, non-POD-union (or array of such types) or reference, and has no user-defined copy assignment operator and no user-defined destructor. A POD class is a class that is either a POD-struct or a POD-union.

@pdimov
Copy link
Member

pdimov commented Apr 29, 2019

It's true that endian_buffer is not a C++03 POD, but there's a test that it can be used in a union, and this test passes. So I'm not sure that making the data member public is really necessary in practice.

@pdimov
Copy link
Member

pdimov commented Oct 7, 2020

Should be fixed in develop.

@pdimov pdimov closed this as completed Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants