cpptoml icon indicating copy to clipboard operation
cpptoml copied to clipboard

Explicitly std::move to avoid copying on older compilers.

Open ldav1s opened this issue 6 years ago • 1 comments

See http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1579 for more details.

ldav1s avatar Nov 19 '19 19:11 ldav1s

Discovered when compiling with clang++-8:

cpptoml.h:1725:12: error: prior to the resolution of a defect report against ISO
      C++11, local variable 'result' would have been copied despite being returned by name, due to its not
      matching the function return type ('shared_ptr<cpptoml::base>' vs 'shared_ptr<cpptoml::array>')
      [-Werror,-Wreturn-std-move-in-c++11]
    return result;
           ^~~~~~
cpptoml.h:1725:12: note: call 'std::move' explicitly to avoid copying on older
      compilers
    return result;
           ^~~~~~
           std::move(result)

ldav1s avatar Nov 19 '19 19:11 ldav1s