tud-zih-energy/otf2xx

Emplace method of definition container not forwarding arguments correctly

Closed this issue · 2 comments

In the signature of otf2::definition::container::emplace (see here), should't args be of type Args&&... to enable perfect forwarding?

If so, I think args should be forwarded like so

    std::forward_as_tuple(ref, std::forward<Args>(args)...)

when passing args to emplace of the underlying map (here).

Args&&... seems like a good idea, but I'm not convinced that the forward is required. If you look at cppreference it says that the return value of forward_as_tuple is:

std::tuple<Types&&...>(std::forward<Types>(args)...)

So there is already a forward.

@phijor is correct: https://godbolt.org/g/NPMueV

(expected) Errors:

/opt/compiler-explorer/gcc-8.1.0/include/c++/8.1.0/tuple:1668:70: error: no matching function for call to 'std::__cxx11::basic_string::basic_string(int&, const char*&)'

vs

/opt/compiler-explorer/gcc-8.1.0/include/c++/8.1.0/tuple:1668:70: error: no matching function for call to 'std::__cxx11::basic_string::basic_string(int&, const char*)'