There are two standard containers, when inserting elements into which links do not break (set and list). How to link them to a map so that a link to an element of one container receives a link to another? I use links in order not to allocate again the memory for the elements of both containers + iterators are broken when rehashing according to the documentation. This is what I tried, but does not want to compile:

#include <unordered_set> #include <unordered_map> #include <forward_list> #include <string> #include <functional> int main(){ std::unordered_set<std::string> A; std::forward_list<std::string> B; std::unordered_map<std::reference_wrapper<decltype(A)::value_type>, std::reference_wrapper<decltype(B)::value_type>> AB_linked; } 
  • Give the text of the error. - αλεχολυτ
  • @ älёxölüt a lot of errors when instantiating a template - invalid
  • Probably a problem due to the hash function. You can try something like this - αλεχολυτ
  • @ älёxölüt I did just that, but instead of value_type I took const_pointer and that's it - invalid
  • one
    Give the minimum reproducible example and the text of the error. An example can be drawn up in the form of what I gave on the link, i.e. with all inclusions, etc. (take and compile). Well, the compiler version at the same time. To edit a question, use the edit link question. - αλεχολυτ

0