Skip to content

Commit

Permalink
Fix packed array elements in the runtime to be passed by reference
Browse files Browse the repository at this point in the history
  • Loading branch information
mikir committed Sep 3, 2024
1 parent ee61625 commit f7e0e33
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions compiler/extensions/cpp/runtime/src/zserio/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,39 @@ void checkOffset(const OWNER_TYPE&, size_t, size_t)

// call the initContext method properly on packed array traits
template <typename PACKED_ARRAY_TRAITS, typename OWNER_TYPE, typename PACKING_CONTEXT,
typename std::enable_if<has_owner_type<PACKED_ARRAY_TRAITS>::value, int>::type = 0>
typename std::enable_if<has_owner_type<PACKED_ARRAY_TRAITS>::value &&
!std::is_scalar<typename PACKED_ARRAY_TRAITS::ElementType>::value,
int>::type = 0>
void packedArrayTraitsInitContext(const OWNER_TYPE& owner, PACKING_CONTEXT& context,
const typename PACKED_ARRAY_TRAITS::ElementType& element)
{
PACKED_ARRAY_TRAITS::initContext(owner, context, element);
}

template <typename PACKED_ARRAY_TRAITS, typename OWNER_TYPE, typename PACKING_CONTEXT,
typename std::enable_if<has_owner_type<PACKED_ARRAY_TRAITS>::value &&
std::is_scalar<typename PACKED_ARRAY_TRAITS::ElementType>::value,
int>::type = 0>
void packedArrayTraitsInitContext(
const OWNER_TYPE& owner, PACKING_CONTEXT& context, typename PACKED_ARRAY_TRAITS::ElementType element)
{
PACKED_ARRAY_TRAITS::initContext(owner, context, element);
}

template <typename PACKED_ARRAY_TRAITS, typename OWNER_TYPE, typename PACKING_CONTEXT,
typename std::enable_if<!has_owner_type<PACKED_ARRAY_TRAITS>::value, int>::type = 0>
typename std::enable_if<!has_owner_type<PACKED_ARRAY_TRAITS>::value &&
!std::is_scalar<typename PACKED_ARRAY_TRAITS::ElementType>::value,
int>::type = 0>
void packedArrayTraitsInitContext(
const OWNER_TYPE&, PACKING_CONTEXT& context, const typename PACKED_ARRAY_TRAITS::ElementType& element)
{
PACKED_ARRAY_TRAITS::initContext(context, element);
}

template <typename PACKED_ARRAY_TRAITS, typename OWNER_TYPE, typename PACKING_CONTEXT,
typename std::enable_if<!has_owner_type<PACKED_ARRAY_TRAITS>::value &&
std::is_scalar<typename PACKED_ARRAY_TRAITS::ElementType>::value,
int>::type = 0>
void packedArrayTraitsInitContext(
const OWNER_TYPE&, PACKING_CONTEXT& context, typename PACKED_ARRAY_TRAITS::ElementType element)
{
Expand Down

0 comments on commit f7e0e33

Please sign in to comment.