drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.06k stars 1.06k forks source link

Build error after reinstalling Docker #1971

Closed UInSomnia closed 3 months ago

UInSomnia commented 3 months ago

Hello! Can you tell me what the error is and how to fix it? The code used to work, I didn't change anything. Docker crashed in my Windows, I restored Docker. And now this error appears during assembly

/shared_dir/Plate/controllers/InSomnia_Files_Manager.cc: In member function ‘void InSomnia::Files_Manager::upload(const HttpRequestPtr&, CALL_BACK&&) const’:
/shared_dir/Plate/controllers/InSomnia_Files_Manager.cc:21:88: error: invalid initialization of reference of type ‘const std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >&’ from expression of type ‘drogon::SafeStringMap<std::__cxx11::basic_string<char> >’ {aka ‘const std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>, drogon::utils::internal::SafeStringHash, std::equal_to<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > > >’}
   21 |     const std::map<std::string, std::string> &parameters    = file_upload.getParameters();
      |                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~^~
make[2]: *** [CMakeFiles/Plate.dir/build.make:104: CMakeFiles/Plate.dir/controllers/InSomnia_Files_Manager.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:100: CMakeFiles/Plate.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Thank you in advance for your help!

UInSomnia commented 3 months ago

const SafeStringMap<std::string> &getParameters() const; SafeStringMap what is it extends to?

Mis1eader-dev commented 3 months ago

The type of the map has been changed in one of the recent commits to unordered_map, and it uses a custom hash on top of that. I believe it is now typed drogon::utils::SafeStringMap, or to be safe, you can use auto.

UInSomnia commented 3 months ago

Thanks for the answer! And I wrote it that way and it works fine. Do you have Namespace Utils in inline? drogon::SafeStringMap

Mis1eader-dev commented 3 months ago

I don't know what you mean, but I forgot to also let you know it should be const auto& to make sure it doesn't copy the entire map. Can you elaborate further on what you mean?

UInSomnia commented 3 months ago

You say to use drogon::utils::SafeStringMap However, I have a successful build like this drogon::SafeStringMap What could be the explanation for this?

UInSomnia commented 3 months ago

I looked at the inside of the library. The Safe String Map is located in the drogon namespace, without namespace utils

Mis1eader-dev commented 3 months ago

Yeah it probably resides in the drogon namespace, I was unsure whether it's in drogon::utils or somewhere else. I'll close this issue as solved.