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

Replace std::is_trivially_assignable with std::is_trivially_copy_assignable #2754

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 1 addition & 3 deletions pxr/base/vt/traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ struct VtIsArray : public std::false_type {};
// space but do not have a trivial assignment are not cheap to copy. E.g. std::
// containers. Clients can specialize this template for their own types that
// aren't trivially assignable but are cheap to copy to enable local storage.
// In C++17, std::is_trivially_copy_assignable<T> could be used in place of
// std::is_trivially_assignable
template <class T>
struct VtValueTypeHasCheapCopy : std::is_trivially_assignable<T&, const T&> {};
struct VtValueTypeHasCheapCopy : std::is_trivially_copy_assignable<T> {};

#define VT_TYPE_IS_CHEAP_TO_COPY(T) \
template <> struct VtValueTypeHasCheapCopy<TF_PP_EAT_PARENS(T)> \
Expand Down
10 changes: 4 additions & 6 deletions pxr/base/vt/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,12 @@ class VtValue
typedef std::aligned_storage<
/* size */_MaxLocalSize, /* alignment */_MaxLocalSize>::type _Storage;

// In C++17, std::is_trivially_copy_assignable<T> could be used in place of
// std::is_trivially_assignable
template <class T>
using _IsTriviallyCopyable = std::integral_constant<bool,
std::is_trivially_default_constructible<T>::value &&
std::is_trivially_copyable<T>::value &&
std::is_trivially_assignable<T&, const T&>::value &&
std::is_trivially_destructible<T>::value>;
std::is_trivially_default_constructible_v<T> &&
std::is_trivially_copyable_v<T> &&
std::is_trivially_copy_assignable_v<T> &&
std::is_trivially_destructible_v<T>>;

// Metafunction that returns true if T should be stored locally, false if it
// should be stored remotely.
Expand Down
11 changes: 4 additions & 7 deletions pxr/usd/usd/crateFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,10 @@ namespace Usd_CrateFile {

// XXX: These checks ensure VtValue can hold ValueRep in the lightest
// possible way -- WBN not to rely on internal knowledge of that.
static_assert(std::is_trivially_constructible<ValueRep>::value, "");
static_assert(std::is_trivially_copyable<ValueRep>::value, "");
// In C++17, std::is_trivially_copy_assignable<T> could be used in place of
// std::is_trivially_assignable
static_assert(std::is_trivially_assignable<ValueRep&, const ValueRep&>::value,
"");
static_assert(std::is_trivially_destructible<ValueRep>::value, "");
static_assert(std::is_trivially_constructible_v<ValueRep>);
static_assert(std::is_trivially_copyable_v<ValueRep>);
static_assert(std::is_trivially_copy_assignable_v<ValueRep>);
static_assert(std::is_trivially_destructible_v<ValueRep>);

using namespace Usd_CrateValueInliners;

Expand Down
Loading