diff options
author | Max Kellermann <max@musicpd.org> | 2020-03-13 19:37:59 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-03-13 20:01:10 +0100 |
commit | 45b60b3d38d80dc8995dfff463ab33e6bfbace3e (patch) | |
tree | ea9620ba4a2687adc5720a004e9ed178b101aa33 /src/fs | |
parent | cefc773992bcb87feb2874ea4b7a94ba8117ba44 (diff) |
fs/Traits: GetParent() returns std::string_view
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/Traits.cxx | 8 | ||||
-rw-r--r-- | src/fs/Traits.hxx | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/fs/Traits.cxx b/src/fs/Traits.cxx index 555e6d72d..f31bcf7c1 100644 --- a/src/fs/Traits.cxx +++ b/src/fs/Traits.cxx @@ -64,7 +64,7 @@ GetBasePathImpl(typename Traits::const_pointer p) noexcept } template<typename Traits> -typename Traits::string +typename Traits::string_view GetParentPathImpl(typename Traits::const_pointer p) noexcept { #if !CLANG_CHECK_VERSION(3,6) @@ -81,7 +81,7 @@ GetParentPathImpl(typename Traits::const_pointer p) noexcept if (Traits::IsDrive(p) && sep == p + 2) return {p, 3u}; #endif - return {p, sep}; + return {p, size_t(sep - p)}; } template<typename Traits> @@ -130,7 +130,7 @@ PathTraitsFS::GetBase(PathTraitsFS::const_pointer p) noexcept return GetBasePathImpl<PathTraitsFS>(p); } -PathTraitsFS::string +PathTraitsFS::string_view PathTraitsFS::GetParent(PathTraitsFS::const_pointer p) noexcept { return GetParentPathImpl<PathTraitsFS>(p); @@ -168,7 +168,7 @@ PathTraitsUTF8::GetBase(const_pointer p) noexcept return GetBasePathImpl<PathTraitsUTF8>(p); } -PathTraitsUTF8::string +PathTraitsUTF8::string_view PathTraitsUTF8::GetParent(const_pointer p) noexcept { return GetParentPathImpl<PathTraitsUTF8>(p); diff --git a/src/fs/Traits.hxx b/src/fs/Traits.hxx index c604110bc..4e8f105a1 100644 --- a/src/fs/Traits.hxx +++ b/src/fs/Traits.hxx @@ -138,7 +138,7 @@ struct PathTraitsFS { * separator in the given input string. */ gcc_pure gcc_nonnull_all - static string GetParent(const_pointer p) noexcept; + static string_view GetParent(const_pointer p) noexcept; /** * Determine the relative part of the given path to this @@ -247,7 +247,7 @@ struct PathTraitsUTF8 { * separator in the given input string. */ gcc_pure gcc_nonnull_all - static string GetParent(const_pointer p) noexcept; + static string_view GetParent(const_pointer p) noexcept; /** * Determine the relative part of the given path to this |