diff --git a/src/image_int.hpp b/src/image_int.hpp index be46273a..75e6428f 100644 --- a/src/image_int.hpp +++ b/src/image_int.hpp @@ -64,7 +64,7 @@ std::ostream& operator<<(std::ostream& stream, const binaryToStringHelper& bi template struct binaryToStringHelper { - explicit binaryToStringHelper(const Slice myBuf) noexcept : buf_(myBuf) { + constexpr binaryToStringHelper(Slice&& myBuf) noexcept : buf_(std::move(myBuf)) { } // the Slice is stored by value to avoid dangling references, in case we @@ -95,8 +95,8 @@ struct binaryToStringHelper { * the stream throws neither. */ template -inline binaryToStringHelper binaryToString(const Slice sl) noexcept { - return binaryToStringHelper(sl); +constexpr binaryToStringHelper binaryToString(Slice&& sl) noexcept { + return binaryToStringHelper(std::move(sl)); } /// @brief indent output for kpsRecursive in \em printStructure() \em . diff --git a/unitTests/test_image_int.cpp b/unitTests/test_image_int.cpp index c9d6ba18..34f39b5b 100644 --- a/unitTests/test_image_int.cpp +++ b/unitTests/test_image_int.cpp @@ -11,11 +11,11 @@ using Exiv2::Slice; static const unsigned char b[10] = {'a', 'b', 'c', 1, 4, 0, 'e', 136, 0, 'a'}; template -void checkBinaryToString(const Exiv2::Slice sl, const char* expectedOutput) { +void checkBinaryToString(Exiv2::Slice&& sl, const char* expectedOutput) { // construct the helper manually so that we catch potential invalidation of // temporaries std::stringstream ss; - const binaryToStringHelper helper = binaryToString(sl); + auto helper = binaryToString(std::move(sl)); ss << helper; ASSERT_STREQ(ss.str().c_str(), expectedOutput);