summaryrefslogtreecommitdiff
path: root/zen/string_base.h
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2022-05-22 17:03:17 -0400
committerB. Stack <bgstack15@gmail.com>2022-05-22 17:03:17 -0400
commit2c81be72eef5363736cf1892646c74a3311ee4c1 (patch)
tree3894ba7e10c78750c195381a861da5e8166a6bfd /zen/string_base.h
parentMerge branch 'b11.20' into 'master' (diff)
downloadFreeFileSync-2c81be72eef5363736cf1892646c74a3311ee4c1.tar.gz
FreeFileSync-2c81be72eef5363736cf1892646c74a3311ee4c1.tar.bz2
FreeFileSync-2c81be72eef5363736cf1892646c74a3311ee4c1.zip
add upstream 11.21b11.21
Diffstat (limited to 'zen/string_base.h')
-rw-r--r--zen/string_base.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/zen/string_base.h b/zen/string_base.h
index 693ce118..ace870b9 100644
--- a/zen/string_base.h
+++ b/zen/string_base.h
@@ -7,8 +7,8 @@
#ifndef STRING_BASE_H_083217454562342526
#define STRING_BASE_H_083217454562342526
-#include <algorithm>
#include <atomic>
+#include <utility> //std::exchange
#include "string_tools.h"
@@ -377,8 +377,8 @@ Zbase<Char, SP>::Zbase(const Zbase<Char, SP>& str)
template <class Char, template <class> class SP> inline
Zbase<Char, SP>::Zbase(Zbase<Char, SP>&& tmp) noexcept
{
- rawStr_ = tmp.rawStr_;
- tmp.rawStr_ = nullptr; //usually nullptr would violate the class invarants, but it is good enough for the destructor!
+ rawStr_ = std::exchange(tmp.rawStr_, nullptr);
+ //usually nullptr would violate the class invarants, but it is good enough for the destructor!
//caveat: do not increment ref-count of an unshared string! We'd lose optimization opportunity of reusing its memory!
}
@@ -637,8 +637,8 @@ Zbase<Char, SP>& Zbase<Char, SP>::operator=(Zbase<Char, SP>&& tmp) noexcept
{
//don't use swap() but end rawStr_ life time immediately
this->destroy(rawStr_);
- rawStr_ = tmp.rawStr_;
- tmp.rawStr_ = nullptr;
+
+ rawStr_ = std::exchange(tmp.rawStr_, nullptr);
return *this;
}
@@ -653,4 +653,12 @@ void Zbase<Char, SP>::pop_back()
}
}
+
+//std::hash specialization in global namespace
+template <class Char, template <class> class SP>
+struct std::hash<zen::Zbase<Char, SP>>
+{
+ size_t operator()(const zen::Zbase<Char, SP>& str) const { return zen::hashString<size_t>(str); }
+};
+
#endif //STRING_BASE_H_083217454562342526
bgstack15