Skip to content

Commit

Permalink
pair noexcept with move operations
Browse files Browse the repository at this point in the history
Typically done with noexcept.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb committed May 10, 2023
1 parent 37184fd commit 4c66b44
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/image_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ std::ostream& operator<<(std::ostream& stream, const binaryToStringHelper<T>& bi

template <typename T>
struct binaryToStringHelper {
explicit binaryToStringHelper(const Slice<T> myBuf) noexcept : buf_(myBuf) {
constexpr binaryToStringHelper(Slice<T>&& myBuf) noexcept : buf_(std::move(myBuf)) {
}

// the Slice is stored by value to avoid dangling references, in case we
Expand Down Expand Up @@ -95,8 +95,8 @@ struct binaryToStringHelper {
* the stream throws neither.
*/
template <typename T>
inline binaryToStringHelper<T> binaryToString(const Slice<T> sl) noexcept {
return binaryToStringHelper<T>(sl);
constexpr binaryToStringHelper<T> binaryToString(Slice<T>&& sl) noexcept {
return binaryToStringHelper<T>(std::move(sl));
}

/// @brief indent output for kpsRecursive in \em printStructure() \em .
Expand Down
4 changes: 2 additions & 2 deletions unitTests/test_image_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ using Exiv2::Slice;
static const unsigned char b[10] = {'a', 'b', 'c', 1, 4, 0, 'e', 136, 0, 'a'};

template <typename T>
void checkBinaryToString(const Exiv2::Slice<T> sl, const char* expectedOutput) {
void checkBinaryToString(Exiv2::Slice<T>&& sl, const char* expectedOutput) {
// construct the helper manually so that we catch potential invalidation of
// temporaries
std::stringstream ss;
const binaryToStringHelper<T> helper = binaryToString(sl);
auto helper = binaryToString(std::move(sl));
ss << helper;

ASSERT_STREQ(ss.str().c_str(), expectedOutput);
Expand Down

0 comments on commit 4c66b44

Please sign in to comment.