From a49de4b9f138f46347e3e0616b6d294dadae1c8f Mon Sep 17 00:00:00 2001 From: elsid Date: Sat, 20 Jul 2024 18:46:23 +0200 Subject: [PATCH] Do not allow to construct NormalizedView from std::string To avoid implicit conversion via Normalized which creates NormalizedView from a temporary Normalized. Mark constructors explicit on purpose so there is no ambiguity on implicit conversion when there is an overloaded function like: void f(const Normalized&); void f(NormalizedView); --- components/vfs/pathutil.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/vfs/pathutil.hpp b/components/vfs/pathutil.hpp index 50f16d1804..c836acb032 100644 --- a/components/vfs/pathutil.hpp +++ b/components/vfs/pathutil.hpp @@ -88,6 +88,10 @@ namespace VFS::Path NormalizedView(const Normalized& value) noexcept; + explicit NormalizedView(const std::string&) = delete; + + explicit NormalizedView(std::string&&) = delete; + constexpr std::string_view value() const noexcept { return mValue; } friend constexpr bool operator==(const NormalizedView& lhs, const NormalizedView& rhs) = default;