Say the following code:
unordered_map<string, int> test_map;
string_view fake_str = "Mike";
test_map[fake_str]; // does not work. No viable overloaded operator[] for type...
test_map.at(fake_str); // works.
I think the purpose of string_view
is to reduce copy when passing string to function right?
And []
is also a function. Why I cannot pass string_view to []
?
Thank you!