Compilation error: cannot convert 'std::basic_string_view<char>' to 'const key_type&' {aka 'const zen::Zbase<char>

Get help for specific problems
Posts: 58
Joined: 14 Aug 2022

daviank

Hello,

Could you please help to workaround this compilation error with g++-10? It's the only remaining one, and I'm struggling with it.
Looks like it would need a conversion, but I'm not at ease enough with C++.
base/path_filter.cpp:219:46: error: cannot convert 'std::basic_string_view<char>' to 'const key_type&' {aka 'const zen::Zbase<char>&'}
  219 |         if (relPaths_.contains(makeStringView(pathFirst, sepPos))) //heterogenous lookup!
Detailed error message is below:

Thanks
g++ -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -ffile-prefix-map=freefilesync=. -fstack-protector-strong -Wformat -Werror=format-security -g -std=c++2a -pipe -DWXINTL_NO_GETTEXT_MACRO -I../.. -I../../zenXml -include "zen/i18n.h" -include "zen/warn_static.h" -Wall -Wfatal-errors -Wmissing-include-dirs -Wswitch-enum -Wcast-align -Wnon-virtual-dtor -Wno-unused-function -Wshadow -Wno-maybe-uninitialized -O3 -DNDEBUG `wx-config --version=3.0 --cxxflags --debug=no` -pthread `pkg-config --cflags openssl` `pkg-config --cflags libcurl` `pkg-config --cflags libssh2` `pkg-config --cflags gtk+-3.0` -isystem/usr/include/gtk-3.0 `pkg-config --cflags libselinux` -DHAVE_SELINUX -c base/path_filter.cpp -o /tmp/FreeFileSync_Make/ffs/src/base/path_filter.cpp.o
base/path_filter.cpp: In member function 'bool fff::NameFilter::MaskMatcher::matches(const Zchar*, const Zchar*) const':
base/path_filter.cpp:219:46: error: cannot convert 'std::basic_string_view<char>' to 'const key_type&' {aka 'const zen::Zbase<char>&'}
  219 |         if (relPaths_.contains(makeStringView(pathFirst, sepPos))) //heterogenous lookup!
      |                                ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
      |                                              |
      |                                              std::basic_string_view<char>
compilation terminated due to -Wfatal-errors.
make[1]: *** [Makefile:137: /tmp/FreeFileSync_Make/ffs/src/base/path_filter.cpp.o] Error 1
Posts: 58
Joined: 14 Aug 2022

daviank

Would this be a correct workaround?
--- freefilesync-11.23.orig/FreeFileSync/Source/base/path_filter.cpp
+++ freefilesync-11.23/FreeFileSync/Source/base/path_filter.cpp
@@ -216,7 +216,9 @@ bool NameFilter::MaskMatcher::matches(co
     {
         sepPos = std::find(sepPos, pathLast, FILE_NAME_SEPARATOR);
 
-        if (relPaths_.contains(makeStringView(pathFirst, sepPos))) //heterogenous lookup!
+        const std::basic_string_view<char> basic_string_view_object = makeStringView(pathFirst, sepPos);
+        const zen::Zbase<char>& b = std::string(basic_string_view_object).c_str();
+        if (relPaths_.contains(b)) //heterogenous lookup!
             return true;
 
         if (sepPos == pathLast)