Skip to content

set_member std::move or std::forward? #667

@MonkeybreadSoftware

Description

@MonkeybreadSoftware

Hello,

you have this in reflect_traits_gen.hpp:

template <typename T, typename U> 
void set_member(T&& val, U& result)
{ 
    result = std::move(val); 
} 

Xcode flags std::move here, that it should be std::forward:

.../jsoncons/include/jsoncons/reflect/reflect_traits_gen.hpp:65:14: warning: Forwarding reference passed to std::move(), which may unexpectedly cause lvalues to be moved; use std::forward() instead [bugprone-move-forwarding-reference]
   65 |     result = std::move(val); 
      |              ^
1 warning generated.

So maybe Xcode (clang) is right and it should be std::forward or maybe add a comment to remind us why not.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions