If there is a std::map<std::pair<std::string, std::string>, some_type>
what is the best way to find it s values?
I guess the most obvious one is to do something like this:
map.find(std::make_pair(str1, str2));
but this will lead to a copy-construction of the str1
and str2
strings during the pair construction.
我希望,可能的话是map.find(std:make_pair(std:ref(str1), :ref(str2));
可帮助,但不幸的是,这仍然产生印本。
map.find(std:make_pair(std:move(str1), :move(str2)
应当工作,但应当假设这些指示(str1
,str2
)是吻合的,或者不应移动。
So I m asking if there is any other way to do a the map search without making redundant string copies?
(请注意,使用<代码>std:string_view for the std:map: Key
是NOT的一种选择,因为地图应当有其示意图。 iii