pair noexcept with move operations

Typically done with noexcept.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 2 years ago
parent 37184fd713
commit 4c66b4440a

@ -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
@ -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 .

@ -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);

Loading…
Cancel
Save