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

Allow TypeDesc to be used directly in a C API by forcing it to be POD. #4162

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/include/OpenImageIO/typedesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,7 @@ struct OIIO_UTIL_API TypeDesc {
TypeDesc (string_view typestring);

/// Copy constructor.
OIIO_HOSTDEVICE constexpr TypeDesc (const TypeDesc &t) noexcept
: basetype(t.basetype), aggregate(t.aggregate),
vecsemantics(t.vecsemantics), reserved(0), arraylen(t.arraylen)
{ }
OIIO_HOSTDEVICE constexpr TypeDesc (const TypeDesc &t) noexcept = default;


/// Return the name, for printing and whatnot. For example,
Expand Down Expand Up @@ -365,8 +362,13 @@ struct OIIO_UTIL_API TypeDesc {
#endif
};



// Validate that TypeDesc can be used directly as POD in a C interface.
static_assert(std::is_default_constructible<TypeDesc>(), "TypeDesc is not default constructable.");
static_assert(std::is_trivially_copyable<TypeDesc>(), "TypeDesc is not trivially copyable.");
static_assert(std::is_trivially_destructible<TypeDesc>(), "TypeDesc is not trivially destructible.");
static_assert(std::is_trivially_move_constructible<TypeDesc>(), "TypeDesc is not move constructible.");
static_assert(std::is_trivially_copy_constructible<TypeDesc>(), "TypeDesc is not copy constructible.");
static_assert(std::is_trivially_move_assignable<TypeDesc>(), "TypeDesc is not move assignable.");

// Static values for commonly used types. Because these are constexpr,
// they should incur no runtime construction cost and should optimize nicely
Expand Down
Loading