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 boost::call_traits in pxr/usd/sdf/accessorHelpers.h #2527

Merged
merged 1 commit into from
Jul 27, 2023
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
11 changes: 9 additions & 2 deletions pxr/usd/sdf/accessorHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ SDF_ACCESSOR_CLASS::name_( \

// Convenience macros to provide common combinations of value accessors

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so I think we could make this more complete by adding to the conditional by making it
std::Is_arithmetic::value || std::is_enum::value
All the places I see that use the SDF_DEFINE_TYPED_GET_SET macro are specifically to for enum values which leads me to believe enums were a hole in the original boost call_traits.
However, I'm okay with leaving this as is in your change and following a followup bug to add is_enum and replace the SDF_DEFINED_TYPED_GET_SET usages

// Convert non-trivial types like `std::string` to `const std::string&` while
// preserving the type for `int`, `bool`, `char`, etc.
template <typename T>
using Sdf_SetParameter = std::conditional<
std::is_arithmetic<T>::value, std::add_const_t<T>,
std::add_lvalue_reference_t<std::add_const_t<T>>>;

#define SDF_DEFINE_TYPED_GET_SET(name_, key_, getType_, setType_) \
SDF_DEFINE_GET(name_, key_, getType_) \
SDF_DEFINE_SET(name_, key_, setType_)
Expand All @@ -184,11 +191,11 @@ SDF_DEFINE_CLEAR(name_, key_)

#define SDF_DEFINE_GET_SET(name_, key_, type_) \
SDF_DEFINE_TYPED_GET_SET(name_, key_, type_, \
boost::call_traits<type_>::param_type)
Sdf_SetParameter<type_>::type)

#define SDF_DEFINE_GET_SET_HAS_CLEAR(name_, key_, type_) \
SDF_DEFINE_TYPED_GET_SET_HAS_CLEAR(name_, key_, type_, \
boost::call_traits<type_>::param_type)
Sdf_SetParameter<type_>::type)

#define SDF_DEFINE_IS_SET(name_, key_) \
SDF_DEFINE_IS(name_, key_) \
Expand Down