Project

General

Profile

Bug #1699

[inline] entry methods should use perfect forwarding in C++11

Added by Nils Deppe 18 days ago. Updated 6 days ago.

Status:
New
Priority:
Normal
Assignee:
Category:
-
Target version:
Start date:
09/30/2017
Due date:
% Done:

0%


Description

Currently inline entry methods are not as useful as they could be in C++11 because they do not use perfect forwarding. For example, if I call an inline entry method:

array[i].receive_data(std::move(my_data));

there is a still a copy done, even though in C++11 move semantics can be used to elide the copy. The necessary change to the generated receive_data method is to have:

template <class TemporalId, class ReceiveData_t>
#if __cplusplus >= 201103L
void CProxyElement_AlgorithmArray<
    Tentacle, Metavariables, OrderedActionsList, InboxTagList, TemporalId,
    SpectreArrayIndex,
    InitialDataBox>::receive_data(TemporalId&& impl_noname_1,
                                  ReceiveData_t&& impl_noname_2,
                                  bool enable_if_disabled,
                                  const CkEntryOptions* impl_e_opts)
#else
/* current code */
#endif  // __cplusplus >= 201103L

then for the call to the local object:

#if __cplusplus >= 201103L
obj->template receive_data<ReceiveTag>(std::forward<TemporalId>(impl_noname_1),
                                       std::forward<ReceiveData_t>(impl_noname_2),
                                       enable_if_disabled);
#else
obj->template receive_data<ReceiveTag>(impl_noname_1, impl_noname_2, enable_if_disabled);
#endif

I would argue that without the use of perfect forwarding [inline] entry methods do not actually work as advertised in C++11 and so that is why I'm filing this as a bug rather than a feature request. The current workaround would be to pass a const pointer to a non-const object, then move that, but that does not actually do the same thing: if the sender wanted the receiver to copy the data (ie it's meant to be a const &) then you have a bug.

History

#1 Updated by Sam White 18 days ago

  • Target version set to 6.9.0

#2 Updated by Eric Bohm 6 days ago

  • Assignee set to Eric Mikida

Also available in: Atom PDF