summaryrefslogtreecommitdiff
path: root/zen/string_traits.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <shieldwed@outlook.com>2018-07-29 21:45:13 -0700
committerDaniel Wilhelm <shieldwed@outlook.com>2018-07-29 21:45:13 -0700
commit06c99e6c91d87a91f3e54191670d23e3f4d132b9 (patch)
treea2c82149d6fe802c68365f73e11f3c241c95ef3d /zen/string_traits.h
parent10.1 (diff)
downloadFreeFileSync-06c99e6c91d87a91f3e54191670d23e3f4d132b9.tar.gz
FreeFileSync-06c99e6c91d87a91f3e54191670d23e3f4d132b9.tar.bz2
FreeFileSync-06c99e6c91d87a91f3e54191670d23e3f4d132b9.zip
10.2
Diffstat (limited to 'zen/string_traits.h')
-rwxr-xr-xzen/string_traits.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/zen/string_traits.h b/zen/string_traits.h
index 8187126d..cd7dbf1b 100755
--- a/zen/string_traits.h
+++ b/zen/string_traits.h
@@ -41,10 +41,14 @@ class StringRef
{
public:
template <class Iterator>
- StringRef(Iterator first, Iterator last) : len_(last - first), str_(first != last ? &*first : nullptr) {}
+ StringRef(Iterator first, Iterator last) : len_(last - first),
+ str_(first != last ? &*first : reinterpret_cast<Char*>(this) /*Win32 APIs like CompareStringOrdinal() choke on nullptr!*/)
+ {
+ static_assert(alignof(StringRef) % alignof(Char) == 0); //even though str_ is never dereferenced, make sure the pointer value respects alignment (why? because we can)
+ }
//StringRef(const Char* str, size_t len) : str_(str), len_(len) {} -> needless constraint! Char* not available for empty range!
- Char* data () const { return str_; } //1. no null-termination! 2. may be nullptr!
+ Char* data () const { return str_; } //no null-termination!
size_t length() const { return len_; }
private:
bgstack15